The LEG 8 Call Convention and Other Instructions
Notes
- You know most of this.
- Register usage is on page 109
- Call and return
- x30 is the link register
- BL to call as we saw last notes
- BR x30 to return
- There is on push/pop
- x28 is the stack pointer
- x29 is the frame pointer
- Push:
- subi x28, xzr, #8
- stur reg_to_save, [x28, #0]
- Or even subtract 16, since you are going to push twice.
- Pop is the reverse.
- MOVZ zero and move
- These two allow us to generate larger immediate
-
movz xd, immediate, lsl shift - The entire destination register is set to 0
- The immediate is logically shifted left by the given amount.
- But the shifted amount is fixed
- Because the immediate field is 16 bits long
- So the shifts are multiples of 16
- movz x1, imm, lsl [0:00,16:01, 32:10, 48:11]
- This is in the IW format
- The green card must have a mistake when it lists IM as the type
- Bits 21 and 22 are used for the shift amount.
- MOVK - move and keep
- Similar to movz
- But the register is not cleared.
movz x1, 0xFFFF, lsl 48 movk x1, 0xAAAA, lsl 32 movk x1, 0x5555, lsl 16