Why is STMFD equivalent to STMDB?

Feb 06, 2014 1 Replies

Hi,



I read the following ARM code on line. I do not understand why it said that : STMFD is equivalent to STMDB.


Could you explain it to me?


Thanks,


Function entry: STMFD sp!, {r4-r6,lr} ? ?Store Multiple Full-Descending? ? Equivalent to STMDB (decrement before) ? sp: store to stack ? !: update stack pointer ? {r4-r6,lr}: Stores r4, r5, r6, r14 (lr)


They're just equivalent ways of writing the same thing. If you have a stack which extends downwards as it grows, and the stack pointer points to the last valid element (a 'Full Descending' stack) rather than the next (Empty) gap, to store something you have to first decrement the stack pointer to get the next location to store at - you Decrement Before.

If you're using stacks it's easier to pair up the instructions using stack notation:

STMFD = STMDB (decrement before) = push LDMFD = LDMIA (increment after) = pop

While if you're copying data you probably want to stick to LDMIA/STMIA or some similar pair.

Theo

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required