L8 - ARM Addressing Modes
L8 - ARM Addressing Modes
14 0 1 13 0 0 4 8 217
Addressing Modes
• There are different ways to specify the address of the
operands for any given operations (load, add or branch)
• Addressing modes - The different ways of determining the
address of the operands
• Information contained in the instruction code is the value of
the operand or the address of the result/operand
Addressing Modes (1)
1. Immediate Addressing
• The operand is a constant within the instruction itself
• ADD r2, r0, #5 ; r2 = r0+5
• CMP r0, #1 ; r0 – 1
• MOV r1, #1 ; r1 = 1
2. Register Addressing
• Operand is a register
• ADD r2, r0, r1
5. Immediate offset
• Constant address is added to a base register
• LDR r2, [r0, #8]
6. Register Offset
• Another register is added to the base register
• Array index is in one register and base of the array is in another
• LDR r2, [r0, r1]
Addressing Modes (3)
7. Scaled Register Offset
• Allows the register to be shifted before it is added to the base register
• Useful to turn array index in to a byte address by shifting it left by 2
bits
• LDR r2, [r0, r1, LSL #2]
• The top 4 bits [31:28] are used to specify the conditions under
• which the instruction is executed
• Bits [27:25] identify this as a B or BL instruction
• The L-bit (bit 24) is set if it is a branch with link instruction and clear if it is
a plain branch
• 24-bit signed offset specifies destination of branch in 2's complement form