AArch64 Assembly Course for Raspberry Pi¶
Learn to explain, run and debug small AArch64 programs on 64-bit Raspberry Pi Linux. This twelve-lesson course builds one concept at a time; the required path ends in a checked array project, with advanced topics afterwards.
Where to start¶
The Arm64 Assembly examples on GitHub contain the exact lesson files, category-local CMake presets and finite CTest checks. Follow the direct compiler commands in the lessons, or use the repository's CMake route. GDB and reference lessons reuse earlier samples instead of inventing extra applications.
- New to assembly: begin with tools and the first program, then follow the order below.
- Already reading disassembly: use the roadmap, but check the memory and ABI contracts before adapting snippets.
- Coming from C/C++: complete the foundations; language familiarity does not establish register preservation or legal addressing.
- Looking for GPIO: use C++ Hardware Programming. No wiring, privileged device access or benchmark is required here.
Requirements and scope¶
Basic terminal navigation is enough to start. C drivers are provided with complete commands; Parts 2–3 use basic arrays and declarations, and the last inline-assembly lesson additionally uses C++. Install a native AArch64 GCC/binutils/GDB toolchain as explained in the first lesson. Check userspace and compiler target, not only the board or kernel.
The target is ordinary 64-bit Linux user space. This is not a 32-bit ARM course, a Pico course or bare-metal firmware. You learn selected integer and SIMD operations, not every ISA extension. Atomics, exception levels, the MMU and production unwinding are outside the required path.
Course roadmap¶
Part headings are numbered; individual lesson titles are not, matching the Rust and C++ courses. The left navigation and each lesson's previous/next links follow the same order.
Part 1: Foundations¶
Build, inspect and predict before introducing memory.
- Tools and Your First AArch64 Program: Assemble and link an executable; distinguish kernel entry from a function return.
- Registers and Integer Operations: Predict x/w alias writes, integer operations and constant construction.
- Flags, Branches and Loops: Choose signed/unsigned conditions and test bounded loops.
Part checkpoint: Identify process entry, register widths and the two comparison interpretations. Trace a zero-length loop without executing it.
Part 2: Memory and Functions¶
Separate storage, location and function-boundary obligations.
- Memory, Arrays and Loads: Walk real arrays using correct load widths and byte strides.
- Addresses and Relocations: Separate addresses from contents and inspect linker relocations.
- Functions, Stack and the ABI: Preserve a live value and return address across a nested call.
Part checkpoint: Trace a signed load, identify object relocations and explain which values survive a nested call.
Part 3: Integration and Debugging¶
Test a contract independently, then inspect a failing instruction.
- Calling Assembly from C and C++: Link the same assembly object from explicit C and C++ contracts.
- Debugging with GDB: Step exact instructions and inspect stack/register restoration.
- A Checked Array Project: Combine a signed sum and negative count with an independent oracle.
Part checkpoint: Run the report's empty/boundary fixtures, explain rejected inputs and use GDB to locate a deliberately changed register value.
Part 4: Advanced Topics¶
Add vector and compiler boundaries only after scalar correctness.
- NEON and Scalar Tails: Process full vectors and every remaining scalar element.
- Extended Inline Assembly: Declare the compiler-visible effects of a small assembly statement.
- Reading Specifications and Measuring: Choose the right authority and separate correctness from measurement.
Part checkpoint: Explain every tail length, all inline-assembly effects and what additional evidence a performance claim would require.
How to practise¶
Use a fresh private directory per lesson. Save the complete named files, run the exact build and compare both output and exit status. Predict first, inspect disassembly second, then single-step if the result disagrees. Change one thing at a time; restore the original before moving on.
Each lesson states prerequisites, an observable outcome, expected results, failure checks and a comprehension question with a collapsible answer. Do not treat reading a page or passing a few fixtures as proof that arbitrary inputs are safe.
Verification record¶
The examples are checked as a course, not as isolated snippets. The verification scope is functional correctness, not speed or hardware-I/O improvement. The source repository includes a repeatable verifier that extracts the exact named code blocks from these lessons; it does not maintain a second copy of the examples.
Verified on 20 October 2026 on Raspberry Pi 4B with 64-bit Raspberry Pi OS (Debian 13), kernel 6.18.50+rpt-rpi-v8, GCC 14.2.0 and GNU Binutils 2.44. All 19 named source files were extracted from these lessons. The first program ran; eight C/assembly labs passed at O0 and O2; the alternative C++ caller passed; inline asm passed at O0, O2 and O3. GDB confirmed register widths and SP/x19 restoration, object relocations were inspected, and the deliberately changed width instruction was rejected by its unchanged test. No timing, GPIO, kernel change or background service was involved.
To repeat from the source repository on a computer with Python and authorized SSH access, replace the explicit host alias with your own:
The verifier creates a fresh directory under the Pi's /tmp, builds only extracted lesson sources and uses finite timeouts. It installs nothing and does not modify your lesson directories. Passing these cases is evidence for the stated examples, not proof for arbitrary inputs or all ABI obligations.
The GitHub examples were also built on that Pi with CMake 4.2.3 in both Debug and Release: 14/14 CTest checks passed in each configuration, including the two GDB checks and the deliberate width-error rejection. CMake was temporarily unpacked for verification, not installed system-wide. See the repository's verification record for this separate build route.
Related learning paths¶
- Rust: a separate language course.
- Modern C++: declarations, types, lifetimes and abstractions.
- OS Development: a different, bare-metal scope.