ARM addressing mode
The so-called addressing method is the way that the processor finds the operands required by the instruction based on the information given in the instruction.
One, immediate number addressing
Immediate number addressing, is a special way of addressing, the operand itself is given in the instruction, as long as the removal of the instruction is also taken to the operand. This operand is called an immediate number, and the corresponding addressing method is called immediate number addressing. : The immediate number cannot be the second operand in the instruction. This rule is consistent with the requirement that the left of an assignment statement cannot be a constant in a high-level language. For example, the following directives:
ADD R0 , r0,#0x3f;r0←r0+0x3f
Immediate number, which requires "#" as a prefix.
Second, register addressing
Register addressing is the use of the value in the register as the operand, which is a more efficient way of addressing, the source and the destination operand can be registers.
ADD R0,R1,R2;R0←R1+R2
The effect of this instruction is to add the contents of the register R1 and R2, and the result is stored in the register R0.
Third, register indirect addressing
A register indirection is a register that holds the address of the operand in memory.
For example, the following directives:
LDR R0, [R2];R0←[R2]
Four, base address variable value register
Base Address addressing is the addition of the contents (base address) in the register to the address offset given in the instruction, thus obtaining the address of the operand in memory:
LDR R0, [R1, #4]; R0[R1+4]
V. Relative addressing
Similar to the base address addressing method, the current value of the relative addressing PC pointer is the base, and the address designator in the instruction is the offset, adding the two to get the valid address of the operand. The following program section completes the subroutine call and returns, the jump instruction BL uses the relative addressing method:
Six, multi-register addressing
One instruction completes the transfer of multiple registers, up to 16 registers;
such as: Stmxx r0! , {R1-R5}
Note: xx is any combination of Idab: i-increase; D-minus; a-after; B-first;
There are several issues to consider when implementing such directives:
1), the base address register points to the original addresses have not put a valid value?
2), register list which register is transmitted first?
3), memory address growth direction?
4), after the execution of the instruction, is the base address register pointing to a valid value?
such as: Stmia r0! The answers to {R1-R5} are: yes; R1; low-high;
Why consider so much because of the problem of data restoration;
such as: Stmib r0! , [R1-R5]
Ldmda r0! , [R1-R5]------Restore
Arm addressing mode, Wang Ming learning Learn