Introduction to ARM

The Stack

We need to store the processor state when making nested calls.

The multiple data transfer instructions provide a mechanism for storing state on the stack (pointed to by R13).

The STM and LDM instructions’ modes have aliases for accessing stacks:

FD
Full Descending
ED
Empty Descending
FA
Full Ascending
EA
Empty Ascending

Remarks

As you’ll recall R13 points to the stack.

FD = Full Descending
STMFD/LDMFD = STMDB/LDMIA
ED = Empty Descending
STMED/LDMED = STMDA/LDMIB
FA = Full Ascending
STMFA/LDMFA = STMIB/LDMDA
EA = Empty Ascending
STMEA/LDMEA = STMIA/LDMDB

Anything but a full descending stack is rare!

Examples

STMFD r13!, {r4-r7} – Push R4,R5,R6 and R7 onto the stack.

STMFD

LDMFD r13!, {r4-r7} – Pop R4,R5,R6 and R7 from the stack.

LDMFD

Navigate