Course: Computer Architectures
Source lesson: ARM Stack and Multiple-Register Transfers

The problem

A stack stores values in last-in, first-out order. ARM must still define where the top is, which direction the stack grows, and when the stack pointer moves. Without those conventions, PUSH and POP would be ambiguous.

Two independent choices

Growth direction says what happens to addresses when a value is pushed:

  • Descending: addresses decrease.
  • Ascending: addresses increase.

Stack-pointer meaning says what SP points to:

  • Full: SP points to the most recently stored value.
  • Empty: SP points to the next free position.

The common ARM convention is full descending (FD).

Why full descending uses STMDB

Suppose SP = 1000 points to the current top. A new push must move below that top before storing. DB means decrement before:

STMDB SP!, {r0}

The processor changes SP to 996, stores r0 at 996, and writes 996 back to SP because of !.

Using STMIA SP! would store at the current SP address first, so it would overwrite the existing top. IA means increment after; it is the correct direction for popping a full descending stack, not pushing one.

Why POP uses LDMIA

For a full descending stack, SP already points to the value being removed:

LDMIA SP!, {r0}

The processor loads r0 from the current address, then changes SP from 996 to 1000. The old slot is released.

Therefore:

PUSH {registers} = STMDB SP!, {registers}
POP  {registers} = LDMIA SP!, {registers}

Suffix names

The first letter describes whether the stack pointer points to a Full or Empty entry. The second describes its direction:

SuffixMeaning
FDFull Descending
EAEmpty Ascending

These names are aliases for address-mode combinations. They describe a convention, not a new data-transfer mechanism.

Retrieval questions

Q: If SP points to the current top of a full descending stack, why is STMIA SP! wrong for PUSH?

A: It stores at the current top before changing the address, so it overwrites the existing value. PUSH must decrement first, which is why it uses STMDB.

Q: What does FD mean?

A: Full Descending: SP points to the top value and pushes move toward lower addresses.

Q: What does EA mean?

A: Empty Ascending: SP points to the next free position and pushes move toward higher addresses.