IntroductionGeneral preface information in most computer books.
Chapter 1: Getting Started Provide a bit of background and history of the ARM Processor leading up to the modern 64-bit processors that this book is about. Covers what you need to write programs like those in this book. GNU GCC compiler, GDB, a text editor, etc. Covers hardware you require to run the programs in this book including how to run a Raspberry Pi in 64-bit mode or using another SBC like the NVidia Jetson Nano. Talk about how programs are represented in memory and then how you use an Assembler to generate them. Cover the linking process and give a very small example. The chapter concludes with a simple "Hello World" program written in ARM 64-bit Assembler. About the ARM ProcessorWhat You Will LearnWhy Use AssemblyTools You NeedComputers & NumbersARM Assembly InstructionsCPU RegistersARM Instruction FormatMemoryAbout the GCC AssemblerHello WorldAbout the Starting CommentWhere to StartAssembly InstructionsDataCalling LinuxReverse Engineering Our ProgramThe goal is to always have working sample programs, this is the first, to just ensure the reader can enter, assemble and link.
Chapter 2: Loading, Adding & SubtractingNegative NumbersAbout Two's ComplementAbout Gnome Programmer's CalculatorAbout One's ComplementBig vs. Little EndianAbout Bi-endianPros of Little EndianShifting & RotatingAbout Carry FlagAbout the Barrel ShifterBasics of shifting and rotatingLogical Shift LeftLogical Shift RightArithmetic Shift RightRotate RightRotate Right ExtendMOV/MVNAbout MOVTThe Dreaded Flexible Operand2Register & ShiftSmall Number & RotationMVNMOV ExamplesADD/ADCAdd With CarrySUBChapter 3: Tooling UpNow that we can start to write some longer code, we need to get into debugging. We also introduce makefiles. Cover the basics and typical workflows for writing/debugging programs. GNU MakeRebuilding a fileA Rule for Building .s filesDefining VariablesCross CompilingBuilding for ARM on IntelBuilding for AndroidBuilding for iOSGDBPreparing to DebugBeginning GDBSource Control and Build ServersGitJenkinsChapter 4: Controlling Program FlowIntroduce how to do if/else statements and loops. Introduce design patterns. Talk more about making your programs readable and maintainable. Unconditional BranchAbout the CPSRBranch on ConditionAbout the CMP InstructionLoopsFOR LoopsWhile LoopsIf/Then/ElseLogical OperatorsANDEORORRBICDesign PatternsConverting Integers to AsciiUsing Expressions in Immediate ConstantsStoring a Register to MemoryWhy Not Print in Decimal?Performance of Branch InstructionsMore Comparison InstructionsSummaryChapter 5: Thanks for the MemoriesCovers loading from and storing to the Pi's memory. Indexed memory operation, etc. Defining Memory ContentsLoading a RegisterPC Relative AddressingLoading from MemoryIndexing Through MemoryWrite BackPost-Indexed AddressingConverting to Upper-caseStoring a RegisterDouble RegistersSummaryChapter 6: Functions & the StackStacks on LinuxBranch with LinkNesting Function CallsFunction Parameters & Return ValuesManaging the RegistersSummary of the Function Call AlgorithmUpper-Case RevisitedStack FramesStack Frame ExampleDefining SymbolsOne More OptimizationMacrosInclude DirectiveMacro DefinitionLabelsWhy Macros?SummaryChapter 7: Linux Operating System ServicesCover how Linux system calls work from Assembler. Cover how to do basic file I/O and other useful tasks like timing code. So Many ServicesCalling ConventionStructuresWrappersConverting a File to Upper CaseOpening a FileError CheckingLoopingSummaryChapter 8: Programming GPIO PinsCreate a simple Assembler program to flash some LEDs attached via a breadboard to the GPIO pins. GPIO OverviewIn Linux, Everything is a FileFlashing LEDsMoving Closer to the MetalAbout Raspberry Pi 4 RAMIn Devices, Everything is MemoryRegisters in BitsGPIO Function Select RegistersGPIO Output Set and Clear RegistersMore Flashing LEDsRoot AccessTable DrivenSetting Pin DirectionSetting & Clearing PinsSummaryChapter 9: Interacting with C & PythonUsually people use minimal Assembly code to supplement their programming in other languages. Cover the most common use cases and provide examples of each. Calling C RoutinesPrinting Debug InformationPreserving StateCalling PrintfPassing a StringAdding with Carry RevisitedCalling Assembly Routines from CPackaging our CodeStatic LibraryShared LibraryEmbedding Assembly Code inside C CodeCalling Assembly from PythonSummaryChapter 10: Multiply, Divide & AccumulateMultiplicationExamplesDivisionExampleMultiply & AccumulateVectors & MatricesAccumulate InstructionsDual Multiply with AccumulateExample 1Accessing Matrix ElementsMultiply with AccumulateRegister UsageExample 2SummaryChapter 11: Floating Point OperationsShow how to write Assembler to perform floating point calculations. Show how to do division. Cover the data formats supported here. About Floating Point NumbersNormalization & NaNsRounding ErrorsDefining Floating Point NumbersFPU RegistersFunction Call ProtocolAbout BuildingLoading & Saving FPU RegistersBasic ArithmeticDistance Between PointsFloating Point ConversionsFloating Point ComparisonExampleSummaryChapter 12: Neon CoprocessorExplain Single Instruction Multiple Data (SIMD) programming. Examples from AI and graphics. Give examples and demonstrate how this can speed up your program. The Neon RegistersStay in Your LaneArithmetic Operations4D Vector Distance3x3 Matrix MultiplicationSummaryChapter 13: Reading, Understanding and Hacking CodeHow to use GCC to generate an Assembler listing from higher level language source code, how to use GDB to view Assembly code in memory and how to use Ghidra to reverse engineer a compiled program. Then look at an example of injecting executable code using a buffer overrun. Linux & GCCDivision RevisitedCode Created by GCCReverse Engineering & GhidraOverflowing the BufferSummaryAppendix A: ARM 64-Bit Instruction SetAppendix B: Linux Operating System ServicesAppendix C: Binary FormatsAppendix D: Assembler DirectivesAppendix E: ASCII Character SetReferences
Stephen Smith is a retired Software Architect, located in Gibsons, BC, Canada. He's been developing software since high-school, or way too many years to record. Since retiring he has pursued Artificial Intelligence programming, earned his Advanced HAM Radio License and enjoys mountain biking, hiking, and nature photography. He continues to write his popular technology blog at smist08.wordpress.com.