Stacks Flashcards
How can stacks be imaged
As a stack of paper You can on,y out new things on the top You cannot put new things in the middle You can only take things off the top You can see the top without taking off the top
What does it mean to push an item on a stack
To place an item on the top of the stack
What does it mean to push an item off the stack
To remove an item from the top of the stack
What does SP stand for
Stack pointer
In what register is the system stack SP
R13
What are the four types of stack growth conventions
Full ascending
Full descending
Empty ascending
Empty descending
In a full ascending stack:
- Where does the SP point
- What direction does it grow in memory
- SP points at last item pushed onto the stack
2. Grows from low to high address in memory
In a full descending stack:
- Where does the SP point
- What direction does it grow in memory
- SP points to last item pushed onto stack
2. Grows from high to low address in memory
In a empty ascending stack:
- Where does the SP point
- What direction does it grow in memory
- Sp posts to the next free space in the stack
2. Grows from low to high addresses in memory
In a empty descending stack:
- Where does the SP point
- What direction does it grow in memory
- Sp points to next free space on the stack
2. Grows from low to high addresses in memory
What is it called when we reach stack size limit
Stack overflow
Does popping off get done on its own
No it’s the programmers responsibility
What does LDM do
Load multiple
What does STM so
Store multiple
Eg store contents of registers r1, r2, r3 to memory at the address in r12
STMDB R12, {r1-r3}
DB = decrement before
Load r1, r2, r3 with contents of memory at the address in r12
LDMIA R12, {R1 - R3}
What do the two letters after LDRM and STRM mean
Mode of operation
Ie IA = increment after
DB = decrement before
Does LDM/STM support byte sized memory transfers
No only word sized
Is the order that the registers are specified in the Curley brcakets important
No
In what order will registers be pushed onto stack
The lowest register is always put at the lowest address and the highest register t the highest
Why would you use ! With the sp
To make sure that it gets updated each time
Eg push r3, updating sp
STMDB SP! {R3}
Pop r3 and update SP
LDMIA SP! {r3}
What mode of order is assumed if not specified otherwise
Full descending
Instead of specifying increment after and decrement before, what could you use
FD for full descending eg
STMFD
LDMFD