sbc
Subtract with Carry
SBC <Wd>, <Wn>, <Wm>
Subtracts with borrow (Carry - 1).
Details
Subtracts one register from another with a borrow (carry-in), computing Wd = Wn - (Wm + NOT(C)), where the carry flag is inverted before use as a borrow. All condition flags (N, Z, C, V) are updated: N and Z reflect the result, C is set if no borrow occurred (result ≥ 0 in unsigned arithmetic), and V is set if signed overflow occurred. This is a 32-bit operation; a 64-bit variant (SBC for X-registers) exists with identical semantics.
Pseudocode Operation
Example
SBC w0, w1, w2
Encoding
Binary Layout
0
1
0
11010000
Rm
000000
Rn
Rd
Operands
-
Wd
Destination 32-bit integer register -
Wn
First source / base 32-bit integer register -
Wm
Second source / offset 32-bit integer register
Reference (Arm A64 ISA)
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x5A000000 | SBC <Wd>, <Wn>, <Wm> | A64 | 0 | 1 | 0 | 11010000 | Rm | 000000 | Rn | Rd | ||
| 0xDA000000 | SBC <Xd>, <Xn>, <Xm> | A64 | 1 | 1 | 0 | 11010000 | Rm | 000000 | Rn | Rd |
Description
Subtract with Carry subtracts a register value and the value of NOT (Carry flag) from a register value, and writes the result to the destination register.
Operation
bits(datasize) result; bits(datasize) operand1 = X[n, datasize]; bits(datasize) operand2 = X[m, datasize]; operand2 = NOT(operand2); (result, -) = AddWithCarry(operand1, operand2, PSTATE.C); X[d, datasize] = result;