AArch64 Playgroundlearn
04 · learn
Lessons
Step-by-step lessons that pair a short reading with a live, runnable editor.
filter by tag
- 4.1C in one sittingRead the C that later lessons turn into assembly: types and their sizes, printf and scanf, pointer parameters, the two loop shapes, and arrays.variablesarrays
- 4.2System architecture: what is inside the boxName the parts of a computer, and follow one instruction as the processor fetches, decodes and runs it.system architecture
- 4.3Anatomy of an assembly fileRead a course program line by line: labels, opcodes, operands, comments, directives, m4 names, and the two build steps.armv8 basics
- 4.4Registers and immediatesName the 31 registers and their jobs, write a constant in any of four bases, and build one too wide for a single mov.registersimmediates
- 4.5Printing a string with printfStore a string in .data, put its address in x0, and print it with printf.printing
- 4.6Printing integers and charactersMatch each printf format specifier to a value in the right argument register, at the width the specifier expects.printingformat strings
- 4.7Arithmetic, and the missing remainderWork out formulas with add, sub, mul, madd and msub, divide with sdiv and udiv, and build a remainder from sdiv and msub.armv8 basicsregisters
- 4.8Printing a variable from .dataLoad a value out of .data with two ldr instructions, print it, and store a new value back with str.printingvariables
- 4.9Reading numbers with scanfRead numbers from the keyboard with scanf into .bss slots, then load them into registers to use them.input and outputvariables
- 4.10Conditionals with cmp and b.condHow cmp sets the condition flags and how b.cond reads them to build an if, an if-else, and an else-if chain.conditionalsbranching
- 4.11Pre-test loopsHow to build a for or while loop, where the condition is checked before every pass, so the body can run zero times.loopspre-test loop
- 4.12Post-test loopsHow to build a do-while loop, where the body runs once before the first test, and when that changes what a loop prints.loopspost-test loop
- 4.13Decisions in one instruction: csel, cinc, and cbzPick one of two values with csel, count with cinc and cset, and branch on zero with cbz and cbnz, in fewer lines than cmp and b.cond need.conditionalsbranching
- 4.14Binary, hex, and octal: one number, many spellingsRead one bit pattern as unsigned, as two's complement, in hex and in octal, and know the range each size can hold.binary arithmeticformat strings
- 4.15Binary logic: masks, flags, and tstSet, clear, flip and test chosen bits of a register with orr, bic, eor, and and tst, using masks.binary logicbitwise
- 4.16Shifts, sign extension, and bitfieldsShift and rotate bits, widen narrow values with sign or zero extension, and pack or unpack fields with bfi and ubfx.bitwisebinary logic
- 4.17Binary arithmetic: flags, carries, and wide numbersPredict the N, Z, C and V flags after an add or a subtract, pick a signed or an unsigned branch, and add numbers wider than 64 bits.binary arithmeticbranching
- 4.18Memory: loads, stores, and addressing modesLoad and store 1, 2, 4 and 8 bytes with the right extension, and reach memory through offsets, index registers, and pointers that move themselves.memory and the stack
- 4.19The stack and the frame pointerOpen a stack frame that saves fp and lr, keep locals at fp offsets, read input straight into them, and keep sp 16-byte aligned.stackframe pointermemory and the stack
- 4.20Debugging in the playgroundStop a program at a breakpoint, step it one instruction at a time, and read its registers, watches, stack and memory to find out why it prints the wrong answer.loopsmemory and the stack
- 4.21Arrays in memory, in one and two dimensionsReserve an array in the frame or in .bss and reach any element, in one or two dimensions, as base plus index times size.arraysmemory and the stack
- 4.22Structures as offset tablesLay out a struct as named field offsets with the padding it needs, read and write each field at its own size, and nest one struct inside another.arrays
- 4.23Writing your own subroutinesWrite a subroutine that takes arguments in x0 to x7 and returns in w0 or x0, and know when it needs a frame and when a macro would do.subroutinesframe pointer
- 4.24Subroutines: saved registers, pointers, and big argumentsKeep the registers a caller counts on, hand back answers through pointers, pass a ninth argument on the stack, and return a large struct through x8.subroutinesstack
- 4.25External data: .data, .bss, and .textChoose where a variable lives (the frame, .data, .bss or .text) and reach each one by its label.external datavariables
- 4.26Strings, pointer arrays, and argvHandle text as bytes: character codes, strings that end in a zero byte, tables of string addresses, and the arguments main receives.stringscommand-line arguments
- 4.27Splitting a program across filesSplit a program into files, share labels between them with .global, and build it so the linker can join the pieces, C files included.external datasubroutines
- 4.28Floating point: the other register fileLoad, compute with, convert, compare, and print single and double values, and pass them to and from functions in d0 to d7.floating pointregisters
- 4.29Vectors: one instruction, many numbersRead a 128-bit v register as lanes of bytes, halfwords, words or doublewords, and add, multiply, or total every lane with one instruction.registersfloating point
- 4.30Talking to the operating system: svc and filesAsk the operating system for input and output with svc: write and read without printf, then create, fill, and read back a file, checking every result.input and output
- 4.31Every instruction is 32 bitsSplit an instruction word into its fields, read the five common formats, and encode a simple instruction by hand.armv8 basicssystem architecture
- 4.32Inside a float: IEEE 754Split a single or double into its sign, exponent, and fraction, convert between decimal and bits by hand, and spot zero, subnormals, infinity, and NaN.floating pointbinary arithmetic