Download presentation
Presentation is loading. Please wait.
1
The Stack
2
The Stack ARMSim memory space: 0x11400 + Unused 0x09400-0x11400 Stack
Heap 0x?????-0x01400 Data 0x x????? Text 0x x01000 Reserved
3
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)
4
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)
5
Stack possibilites ARM Convention : Full Descending
r13 Points to "top" item (lowest address) in stack Stack view of memory flipped
6
Push Recipe Subtract 4 from sp … 81818181 0x113F4 0x113F8 0x113FC
????????? sp 0x11400
7
Push Recipe Subtract 4 from sp … 81818181 0x113F4 0x113F8 0x113FC
????????? sp 0x113FC
8
Push Recipe Subtract 4 from sp STR data … 81818181 0x113F4 0x113F8
0x113FC AA 0x11400 ????????? sp 0x113FC
9
Push Recipe Subtract 4 from sp … 81818181 0x113F4 0x113F8 0x113FC AA
????????? sp 0x113F8
10
Push Recipe Subtract 4 from sp STR data … 81818181 0x113F4 0x113F8 BB
0x113FC AA 0x11400 ????????? sp 0x113F8
11
Pop Recipe LDR data … 81818181 0x113F4 0x113F8 BB 0x113FC AA 0x11400
????????? sp 0x113F8
12
Pop Recipe LDR data Add 4 to sp … 81818181 0x113F4 0x113F8 BB 0x113FC
????????? sp 0x113FC
13
Pop Recipe LDR data … 81818181 0x113F4 0x113F8 BB 0x113FC AA 0x11400
????????? sp 0x113FC
14
Pop Recipe LDR data Add 4 to sp … 81818181 0x113F4 0x113F8 BB 0x113FC
????????? sp 0x11400
15
Push / Pop Always tear down stack in reverse order Push A Push B Pop B
Time
16
Machine Push/Pop Fun Fact Common need : machine instructions
Store Multiple to Full Descending use sp and update it (!) store r1 and r2
17
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)
18
Pseudo Instructions Easier pseudinstructions: PUSH {register list} POP {register list}
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.