11.94 RSB

Reverse Subtract without carry.

Syntax

RSB{S}{cond} {Rd}, Rn, Operand2

where:

S

is an optional suffix. If S is specified, the condition flags are updated on the result of the operation.

cond

is an optional condition code.

Rd

is the destination register.

Rn

is the register holding the first operand.

Operand2

is a flexible second operand.

Operation

The RSB instruction subtracts the value in Rn from the value of Operand2. This is useful because of the wide range of options for Operand2.

In certain circumstances, the assembler can substitute one instruction for another. Be aware of this when reading disassembly listings.

Use of PC and SP in Thumb instructions

You cannot use PC (R15) for Rd or any operand.

You cannot use SP (R13) for Rd or any operand.

Use of PC and SP in ARM instructions

You cannot use PC for Rd or any operand in an RSB instruction that has a register-controlled shift.

Use of PC for any operand, in instructions without register-controlled shift, is deprecated.

If you use PC (R15) as Rn or Rm, the value used is the address of the instruction plus 8.

If you use PC as Rd:

  • Execution branches to the address corresponding to the result.

  • If you use the S suffix, see the SUBS pc,lr instruction.

Use of SP in RSB ARM instructions is deprecated.

Note:

The deprecation of SP and PC in ARM instructions is only in ARMv6T2 and above.

Condition flags

If S is specified, the RSB instruction updates the N, Z, C and V flags according to the result.

16-bit instructions

The following forms of this instruction are available in Thumb code, and are 16-bit instructions:

RSBS Rd, Rn, #0

Rd and Rn must both be Lo registers. This form can only be used outside an IT block.

RSB{cond} Rd, Rn, #0

Rd and Rn must both be Lo registers. This form can only be used inside an IT block.

Example

    RSB     r4, r4, #1280       ; subtracts contents of R4 from 1280
Non-ConfidentialPDF file icon PDF versionARM DUI0473M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.