4.2.9. PUSH and POP

Push registers onto, and pop registers off a full descending stack.

Syntax

PUSH{cond} reglist
POP{cond} reglist

where:

cond

is an optional condition code (see Conditional execution).

reglist

is a non-empty list of registers, enclosed in braces.It can contain register ranges. It must be comma separated if it contains more than one register or register range.

Usage

PUSH and POP are synonyms for STMDB and LDM (or LDMIA), with the base register sp (r13), and the adjusted address written back to the base register. PUSH and POP are the preferred mnemonic in these cases.

Registers are stored on the stack in numerical order, with the lowest numbered register at the lowest address.

POP, with reglist including the pc

This instruction causes a branch to the address popped off the stack into the pc. This is usually a return from a subroutine, where the lr was pushed onto the stack at the start of the subroutine.

In ARMv5T and above:

  • bits[1:0] must not be 0b10

  • if bit[0] is 1, execution continues in Thumb state

  • if bit[0] is 0, execution continues in ARM state.

In ARMv4, bits[1:0] of the address loaded must be 0b00. POP cannot be used to change state.

Thumb instructions

A subset of these instructions are available in the Thumb instruction set.

The following restrictions apply to the 16-bit instructions:

  • For PUSH, reglist can only include the Lo registers and the lr

  • For POP, reglist can only include the Lo registers and the pc.

The following restrictions apply to the 32-bit instructions:

  • reglist must not include the sp

  • For PUSH, reglist must not include the pc

  • For POP, reglist can include either the lr or the pc, but not both.

Restrictions on reglist in ARM instructions

ARM PUSH instructions can have SP and PC in the reglist but these instructions that include SP or PC in the reglist are deprecated.

ARM POP instructions can have SP and PC in the reglist but these instructions that include SP in the reglist or both PC and LR in the reglist are deprecated.

Examples

    PUSH    {r0,r4-r7}
    PUSH    {r2,lr}
    POP     {r0,r10,pc} ; no 16-bit version available
Copyright © 2002-2010 ARM. All rights reserved.ARM DUI 0204J
Non-ConfidentialID101213