Master the fundamental concepts of arm assembly (aarch64) through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksThe AArch64 Procedure Call Standard places arguments in x0-x7, returns scalars in x0, and keeps x19-x28 callee-saved. x29 is the frame pointer; x30 is the link register holding the return address. Swift, JNI, and kernel syscall wrappers all obey this map.
asmLoading…
Typical prologue:
asmLoading…
sp must be 16-byte aligned before bl. bl writes the return address into lr.
For this exercise, you will implement add and a caller that bls it. This task asks you to preserve callee-saved registers if you use them, because arm64e pointer authentication on Apple platforms assumes frames were built correctly.
Keep the relevant man page, ABI doc, or Rust reference chapter open while you work. When your output disagrees with the reference implementation on the same machine, the mismatch is usually an alignment rule, an off-by-one terminator, or a register slot you misread in GDB. Skim the official documentation for the tool or ABI named in the exercise; the prose changes, but register roles, syscall numbers, and ownership rules stay stable across releases. Treat each failure as a contract test: the CPU, kernel, and borrow checker enforce rules whether or not the tutorial mentioned them explicitly.
Write three functions in AArch64 assembly that follow AAPCS64, the procedure call standard every ARM64 compiler uses: arguments in x0-x7, the result in x0, bl to call and ret to return through x30.
asmLoading…
sqsum is the real exercise. bl overwrites x30, so save it (stp x29, x30, [sp, #-32]!) before the first call, and restore it before ret.stp/ldp), because the harness keeps its own state there. A function that calls another with bl must save x30 (the return address) first.The harness reads one command, calls your function, and prints the result.
One line: add A B, mul A B or sqsum A B, with signed 64-bit integers.
The result on one line: 8 for add 5 3, 25 for sqsum 3 4.
ARM code is not run on this site yet. Submit completes the task once your code assembles for AArch64 and still declares and defines every .global symbol in the starter. The tests below show exactly what a correct program prints, so you can run it yourself: aarch64-linux-gnu-as, aarch64-linux-gnu-ld and qemu-aarch64, or natively on an ARM Linux machine.