Hardware stacks

Area of memory that grows and shrinks according to the LIFO (last in, first out) principle

Stack models

There are four models of different position sp register points.

Full Ascending

Empty Ascending

Full Descending

Empty Descending

AAPCS specifies Full Descending stack, 8-byte width.

Stack pointer points to an address divisible by 8, say, 0x400.
In the block of 0x400, there are 8 bytes. The next block is 0x408.

Store multiple decrement before (overwrite)

STMDB sp!, {r0, r1}
SUB sp, sp, #8
STR r0, [sp]
STR r1, [sp, #4]
push {r0, r1}

STM can operate on other registers, whilst push only operates on the stack pointer.

STMDB sp!, {r0, r1}
ADD sp, sp, #8 
@ equivalent to pop, but pop doesn't work here.
LDMIA sp!, {r0, r1}
@ increment after (pop)
Published on November 20, 2015