Stack: Difference between revisions

Content added Content deleted
m (Ol: removed deprecated function call)
Line 735: Line 735:


<lang ARM Assembly>LDR r0,[sp] ;load the top of the stack into r0</lang>
<lang ARM Assembly>LDR r0,[sp] ;load the top of the stack into r0</lang>

The order in which registers are pushed/popped is always the same, no matter which order you list the registers in your source code. If you want to push some registers and purposefully pop them into different registers, you'll need to push/pop them separately.


A check if the stack is empty is also very simple, provided the initial value of the stack pointer was saved at the start of the program, or (more likely) was loaded from a nearby memory location.
A check if the stack is empty is also very simple, provided the initial value of the stack pointer was saved at the start of the program, or (more likely) was loaded from a nearby memory location.