RSC

From ARMwiki
(Difference between revisions)
Jump to: navigation, search
(Created.)
 
(Added more descriptive title.)
 
Line 8: Line 8:
 
}}
 
}}
  
==RSC[S]==
+
==RSC[S] : Reverse Subtract with Carry==
 
RSC will subtract one value from another, with Borrow (NOT Carry). As for [[RSB]], the subtraction is performed in reverse, with operand 2 being the value subtracted from.
 
RSC will subtract one value from another, with Borrow (NOT Carry). As for [[RSB]], the subtraction is performed in reverse, with operand 2 being the value subtracted from.
  

Latest revision as of 08:06, 22 December 2011

RSC
Instruction RSC[S]
Function Subtraction
Category Data processing
ARM family All
Notes -

Contents

[edit] RSC[S] : Reverse Subtract with Carry

RSC will subtract one value from another, with Borrow (NOT Carry). As for RSB, the subtraction is performed in reverse, with operand 2 being the value subtracted from.

Operand 1 is a register, operand 2 can be a register, shifted register, or an immediate value (which may be shifted).

If the S bit is set (RSCS), the N and Z flags are set according to the result, and the C and V flags are set as follows: C if the result generated a borrow (a not-carry; unsigned underflow); V if the result generated a signed overflow.

RSC is used for multi-word negation. When used with RSB, you can perform 64 bit (etc) calculations.

[edit] Syntax

  RSC<suffix>  <dest>, <op 1>, <op 2>

[edit] Function

  dest = op_2 - op_1 - NOT(Carry)

[edit] Example

To negate a 64 bit value (held in R0,R1) and write the result to R4,R5; you would:

  RSBS R4, R0, #0
  SBC  R5, R1, #0

[edit] Technical

The instruction bit pattern is as follows:

31 - 28 27 26 25 24 - 21 20 19 - 16 15 - 12 11 - 0
condition 0 0 I 1 1 1 1 S op_1 dest op_2/shift
Personal tools
Namespaces

Variants
Actions
Navigation
Contents
Toolbox