Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arm assembly - multiple push/pop order and SP

Tags:

stack

arm

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?

like image 819
Niv Avatar asked Jul 20 '13 16:07

Niv


1 Answers

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.

like image 89
Carl Norum Avatar answered Oct 18 '22 02:10

Carl Norum