sbcs
Subtract with Carry and Set Flags
SBCS <Wd>, <Wn>, <Wm>
Subtracts with borrow and updates flags.
Pseudocode Operation
result ← Wn - Wm - (1 - C)
Wd ← result[31:0]
N ← result[31]
Z ← (result == 0)
C ← NOT(BorrowFrom(Wn - Wm - (1 - C)))
V ← OverflowFrom(Wn - Wm - (1 - C))
Example
SBCS w0, w1, w2
Encoding
Binary Layout
0
31
1
30
1
29
11010000
28:21
Rm
20:16
000000
15:10
Rn
9:5
Rd
4:0
Operands
-
Wd
Destination 32-bit integer register -
Wn
First source / base 32-bit integer register -
Wm
Second source / offset 32-bit integer register
Related
More in Base
Reference
View in Arm A64 ISA Reference ↗
Arm A64 ISA
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x7A000000 | SBCS <Wd>, <Wn>, <Wm> | A64 | 0 | 1 | 1 | 11010000 | Rm | 000000 | Rn | Rd | ||
| 0xFA000000 | SBCS <Xd>, <Xn>, <Xm> | A64 | 1 | 1 | 1 | 11010000 | Rm | 000000 | Rn | Rd |
Description
Subtract with Carry, setting flags, subtracts a register value and the value of NOT (Carry flag) from a register value, and writes the result to the destination register. It updates the condition flags based on the result.
Operation
bits(datasize) result; bits(datasize) operand1 = X[n, datasize]; bits(datasize) operand2 = X[m, datasize]; bits(4) nzcv; operand2 = NOT(operand2); (result, nzcv) = AddWithCarry(operand1, operand2, PSTATE.C); PSTATE.<N,Z,C,V> = nzcv; X[d, datasize] = result;