Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why is STMFD equivalent to STMDB?

624 views
Skip to first unread message

Robert Willy

unread,
Feb 6, 2014, 5:13:12 PM2/6/14
to
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)

Theo Markettos

unread,
Feb 6, 2014, 5:55:01 PM2/6/14
to
Robert Willy <rxj...@gmail.com> wrote:
> Hi,
>
> I read the following ARM code on line. I do not understand why it said that:
> STMFD is equivalent to STMDB.

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
0 new messages