3 add and sub, sp – ARM VERSION 1.2 User Manual

Page 213

Advertising
background image

Thumb Instruction Reference

ARM DUI 0068B

Copyright © 2000, 2001 ARM Limited. All rights reserved.

5-19

5.2.3

ADD and SUB, sp

Increment or decrement sp by an immediate constant.

Syntax

ADD sp, #expr

SUB sp, #expr

where:

expr

is an expression that evaluates (at assembly time) to a multiple of 4 in the
range –508 to +508.

Usage

This instruction adds the value of

expr

to the value from

Rp

, and places the result in

Rd

.

Note

An

ADD

instruction with a negative value for

expr

assembles to the corresponding

SUB

instruction with a positive constant. A

SUB

instruction with a negative value for

expr

assembles to the corresponding

ADD

instruction with a positive constant.

Be aware of this when looking at disassembly listings.

Condition flags

This instruction does not affect the flags.

Architectures

This instruction is available in all T variants of the ARM architecture.

Examples

ADD sp,#312
SUB sp,#96
SUB sp,#abc+8 ; abc + 8 must evaluate at assembly time to
; a multiple of 4 in the range –508 to +508

Advertising