What happens to the stack pointer (SP) when the ARM instruction PUSH {R0, R1} is executed?
Remember that ARM stack grows downwards in memory.
In ARM, the stack grows downward. The PUSH instruction decreases the stack pointer by the total size of the registers pushed (4 bytes each). Then it stores the registers at the new SP address.
After executing POP {R2, R3} in ARM, what is true about R2 and R3?
Consider how the stack pointer moves after popping values.
The POP instruction loads registers from the memory at SP, then increments SP by the total size of the registers popped (4 bytes each).
Given SP starts at 0x1000, what is the value of SP after executing these instructions?
PUSH {R4, R5}
PUSH {R6}
POP {R5}
POP {R4, R6}Calculate SP changes step-by-step considering each PUSH decreases SP and each POP increases SP.
Each PUSH decreases SP by 4 bytes per register, each POP increases SP by 4 bytes per register. After all operations, SP returns to the original 0x1000.
Which statement correctly describes the difference between PUSH and STMFD SP!, {R0-R3} in ARM?
Think about how PUSH is implemented in ARM assembly.
PUSH is an alias for STMFD SP!, {registers}, which stores registers on a full descending stack and updates SP accordingly.
Consider this ARM code snippet:
SUB SP, SP, #12 STR R0, [SP, #8] STR R1, [SP, #4] STR R2, [SP] ADD SP, SP, #8
What is the main issue with this code regarding stack operations?
Check how much SP was decreased and how much it is restored.
SP is decreased by 12 bytes but only increased by 8 bytes at the end, leaving SP misaligned and causing stack corruption.
