# SBC

(Created.) |
(Added more descriptive title.) |
||

Line 8: | Line 8: | ||

}} | }} | ||

− | ==SBC[S]== | + | ==SBC[S] : Subtract with Carry== |

SBC will subtract one value from another, with Borrow (NOT Carry). | SBC will subtract one value from another, with Borrow (NOT Carry). | ||

## Latest revision as of 07:06, 22 December 2011

Instruction | SBC[S] |
---|---|

Function | Subtraction |

Category | Data processing |

ARM family | All |

Notes | - |

## Contents |

## [edit] SBC[S] : Subtract with Carry

SBC will subtract one value from another, with Borrow (NOT Carry).

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 (* SBCS*), 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.

* SBC* is used for multi-word subtraction. When used with SUB, you can perform 64 bit (etc) calculations.

If you should need to perform the subtraction in reverse (i.e. the shifted register/immediate minus register), look at RSB (Reverse SuBtract) and RSC (Reverse Subtract with Carry).

### [edit] Syntax

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

### [edit] Function

dest = op_1 - op_2 - NOT(Carry)

### [edit] Example

If R0 and R1 hold a 64 bit value, and R2 and R3 hold a second, you can subtract the second from the first, leaving the difference in R4 and R5. In each case, the first register specified (R0, R2, R4) holds the least significant word.

SUBS R4, R0, R2 SBC R5, R1, R3

### [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 | 0 1 1 0 | S | op_1 | dest | op_2/shift |