Detailed STMFD and LDMFD instructions and personal understanding analysis

  

LDM/STM instructions are mainly used for field protection, data copying, parameter transfer, etc.

STMFD Instructions

STMFD Rn{!},{reglist}{^}
STMFD Instruction Explanation

Example:
STMFD SP! , {R0-R7, LR}

For the explanation of the pseudo code of this instruction, this is roughly the same:
SP = 9 -times;4;address = SP;for i = 0 to 7Memory[address] = Ri;address = address + 4;Memory[address] = LR;

Assuming the SP address is: 0x40000460, the following figure can be obtained from the pseudo code (blue padding is the address)
Stack indication< Br>

LDMFD instruction

LDMFD Rn{!},{reglist}{^}

The meaning of this instruction is based on Rn (starting address), value Write to the register list.
LDMFD Instruction Explanation

Example:
LDMFD SP! , {R0-R7, PC}^

For the explanation of the pseudo code of this instruction, this is roughly the same:
address = SP; for i = 0 to 7Ri = Memory[address , 4]address = address + 4; SP = address;

Assume that the SP address is: 0x4000043C, the following figure can be obtained from the pseudo code (blue fill area is the address):
LDMFD instruction stack indication

blue The color marked SP is the SP address before the execution of the instruction, and the red marked SP is the SP address after the execution of the instruction.

Copyright © Windows knowledge All Rights Reserved