gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > Stack question

#7483 - funkeejeffou - Wed Jun 18, 2003 4:26 pm

Let's say that I stack r0=0, r1=1, r4=4 consecutively like that :
stmfd sp!, {r0}
....
stmfd sp!, {r1}
....
stmfd sp!, {r4}
.....

When I unstack in one instructiun all my values :
ldmfd sp! {r0-r2}
Does r0 takes the last value in or the first one, ie:
r0 = 0
r1 = 1
r2 = 4
or
r0 = 4
r1 = 1
r2 = 0

Thanks

#7492 - tepples - Wed Jun 18, 2003 6:04 pm

funkeejeffou wrote:
Let's say that I stack r0=0, r1=1, r4=4 consecutively like that :
stmfd sp!, {r0}
....
stmfd sp!, {r1}
....
stmfd sp!, {r4}
.....

So the content of the stack is 4, 1, 0, ...

Quote:
When I unstack in one instructiun all my values :
ldmfd sp! {r0-r2}

Then the lowest-numbered register gets the value of the lowest memory address: r0 = 4, r1 = 1, r2 = 0. Check this page for more info on the load/store multiple instructions.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.