3

I'm trying to create a factorial method using THUMB instructions, and I'm basically there.

I just have one question about the PUSH/POP opcodes: if I stored the value of r0 in the stack using push (so push {r0}), can I later use pop {r1} to pull it out or do I need to specify the same register as it was in to begin with? Thanks for your help.

4

1 回答 1

4

Yes, you can since push/pop actually expand to store/load multiple, which are generic instructions operating on registers and memory, so

push {r0}

is equivalent to

stmdb sp!, {r0}  @ or stmfd sp!, {r0} in alt notation

and

pop {r1}

is the same as

ldmia sp!, {r1}  @ or ldmfd sp!, {r1}
于 2012-12-03T16:12:32.963 回答