Operands

Register Operands

  • 32 x 64-bit register file
  • Used for frequently accessed data
  • 64-bit data is called a “doubleword”
    • 31 x 64-bit general purpose registers named X0 to X30
  • 32-bit data is called a “word”
    • 31 x 32-bit general purpose registers named W0 to W30
  • Faster than memory, so the compiler picks frequently used values to store in the register
  • Register File

Registers

RegisterUsePreserved
X0-X7Arguments/ResultsNo
X8Indirect Location RegisterNo
X9-X15TemporariesNo
X16, X17 (IP0, IP1)May be used by linker, other times tempNo
X18For platform independent code, otherwise tempNo
X19-27SavedYes
X28 (SP)Stack PointerYes
X29 (FP)Frame pointerYes
X30 (LR)Link register (return address)Yes
X31 (ZR)The constant value 0Yes

Memory Operands

  • Memory is byte addressable
  • LEGv8 addressed by doublewords, which means every address is a multiple of 8
    • So the memory has a 64 bit bus in and out
    • If you don’t access validly (multiple of 8 for doublewords, 4 for words, etc.), it gives an alignment error
  • Access using [XA, #B] where the first is base address and the second is offset

Immediates

  • Stores constants in code
  • Written as #NUM
  • 12-bit number
  • If we need more bits we can create a 32-bit constant through expanding it into a couple instructions

Addressing Modes

  • Immediate: Constant within instruction
  • Register: Operand is a register
  • Displacement: Operand is the at register + constant
  • PC-Relative: PC + Constant