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
Register | Use | Preserved |
---|
X0-X7 | Arguments/Results | No |
X8 | Indirect Location Register | No |
X9-X15 | Temporaries | No |
X16, X17 (IP0, IP1) | May be used by linker, other times temp | No |
X18 | For platform independent code, otherwise temp | No |
X19-27 | Saved | Yes |
X28 (SP) | Stack Pointer | Yes |
X29 (FP) | Frame pointer | Yes |
X30 (LR) | Link register (return address) | Yes |
X31 (ZR) | The constant value 0 | Yes |
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
- 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
