• Load memory data into a register:
    • LDR RD, [Rn, #offset]
    • `LDR Rd,
  • Store register data to memory
    • STR Rd, [Rn, #offset]
  • Move a constant into a register
    • MOV Rd, #const
  • Move an address into a register
    • LDR Rd,=<LABEL>
    • ADR Rd,<LABEL> (pc-relative)
    • If label is close to the instruction, the offset is computed and stored
    • This is a pseudo instruction

Pre/Post Processing

  • Applies to LDR, STR instructions
  • Also updates address register
  • Pre-indexed syntax: address = [Rn, #offset]
    • E.g. LDR R3,[R1,#4]
  • Adding in a loop example

Memory Access

  • Multi-byte data ordering
  • E.g. num=0x1234ABCD
  • See Endianness
  • A memory access is “naturally aligned” if the address is a multiple of the data size; word-size data is stored at an address that’s a multiple of the word size, e.g. 4
    • E.g. if loading contents of R1 into R2, LDR R2, [R1]
    • Good if R1=0,4,8,12… Not good if R1=1,3,5,6, etc.

Assemblers, Linkers, Loaders

  • Assemblers translate assembly into machine code (binary)
    • There’s a one-to-one mapping of assembly to machine instruction
    • Assembly directives (e.g. AREA, ALIGN, DCD) are not translated to machine instructions; they’re “config data” for the assembler
    • Assemblers perform 2 passes on source code (because of forward references, 2 passes is necessary):
      • Pass 1:
        • Determines instruction/data sizes
        • Builds a symbol table
        • Uses an ILC (Instruction Location Counter) to determine label adddresses
      • Pass 2:
        • Encode machine instructions
        • Emits a relocatable object file (.o)
  • Linker joins multiple compiled files together into one executable
  • Loader gets your program into memory so that it’s ready for execution