The Stack
The Stack ARMSim memory space: 0x11400 + Unused 0x09400-0x11400 Stack Heap 0x?????-0x01400 Data 0x01000-0x????? Text 0x00000-0x01000 Reserved
Stack possibilites How to use the space in stack? Grow up Keep track of top item in stack (Full Ascending) Keep track of first empty slot (Empty Ascending)
Stack possibilites How to use the space in stack? Grow down Keep track of top item in stack (Full Descending) Keep track of first empty slot (Empty Descending)
Stack possibilites ARM Convention : Full Descending r13 Points to "top" item (lowest address) in stack Stack view of memory flipped
Push Recipe Subtract 4 from sp … 81818181 0x113F4 0x113F8 0x113FC ????????? sp 0x11400
Push Recipe Subtract 4 from sp … 81818181 0x113F4 0x113F8 0x113FC ????????? sp 0x113FC
Push Recipe Subtract 4 from sp STR data … 81818181 0x113F4 0x113F8 0x113FC AA 0x11400 ????????? sp 0x113FC
Push Recipe Subtract 4 from sp … 81818181 0x113F4 0x113F8 0x113FC AA ????????? sp 0x113F8
Push Recipe Subtract 4 from sp STR data … 81818181 0x113F4 0x113F8 BB 0x113FC AA 0x11400 ????????? sp 0x113F8
Pop Recipe LDR data … 81818181 0x113F4 0x113F8 BB 0x113FC AA 0x11400 ????????? sp 0x113F8
Pop Recipe LDR data Add 4 to sp … 81818181 0x113F4 0x113F8 BB 0x113FC ????????? sp 0x113FC
Pop Recipe LDR data … 81818181 0x113F4 0x113F8 BB 0x113FC AA 0x11400 ????????? sp 0x113FC
Pop Recipe LDR data Add 4 to sp … 81818181 0x113F4 0x113F8 BB 0x113FC ????????? sp 0x11400
Push / Pop Always tear down stack in reverse order Push A Push B Pop B Time
Machine Push/Pop Fun Fact Common need : machine instructions Store Multiple to Full Descending use sp and update it (!) store r1 and r2
Machine Push/Pop Fun Fact Common need : machine instructions Load Multiple from Full Descending use sp and update it (!) load r2 then r1 (reverse order)
Pseudo Instructions Easier pseudinstructions: PUSH {register list} POP {register list}