sbc

Subtract with Carry

SBC <Wd>, <Wn>, <Wm>

Subtracts with borrow (Carry - 1).

Pseudocode Operation

borrow ← NOT(C)
result ← Wn - (Wm + borrow)
Wd ← result
N ← result[31]
Z ← (result == 0)
C ← NOT(BorrowFrom(Wn - (Wm + borrow)))
V ← OverflowFrom(Wn - (Wm + borrow))

Example

SBC w0, w1, w2

Encoding

Binary Layout
0
31
1
30
0
29
11010000
28:21
Rm
20:16
000000
15:10
Rn
9:5
Rd
4:0
 
Format Data Processing
Opcode 0x5A000000
Extension Base

Operands

  • Wd
    Destination 32-bit integer register
  • Wn
    First source / base 32-bit integer register
  • Wm
    Second source / offset 32-bit integer register

Related

Other forms of sbc

  • sbc Subtract with Carry (A32)

More in Base

Reference

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;