Niv
Niv

Reputation: 2312

Arm assembly - multiple push/pop order and SP

I've seen an annotation for pushing/popping multiple registers in the same line, e.g:

push    {fp, lr}

I couldn't find out who is pushed first - fp or lr?

An additional question - does SP point to the last occupied address in the stack or the first free one?

Upvotes: 6

Views: 10467

Answers (1)

Carl Norum
Carl Norum

Reputation: 224972

From the ARM ARM:

The registers are stored in sequence, the lowest-numbered register to the lowest memory address (start_address), through to the highest-numbered register to the highest memory address (end_address)

On ARM, the stack pointer normally points to the last occupied address on the stack. For example, when setting up the initial stack pointer, you normally initialize with with the address one past the end of the stack.

PUSH is just a synonym for STMDB using sp as the base register. The DB indicates the 'decrement-before' addressing mode.

Upvotes: 3

Related Questions