SBC Subtract with Carry
Subtraction with Carry
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |
---|---|---|---|---|---|---|---|---|
\(A \longleftarrow A - r - Carry\) | ||||||||
SBC A, r | ||||||||
1 | 0 | 0 | 1 | 1 | r | |||
\(A \longleftarrow A - n - Carry\) | ||||||||
SBC A,n | ||||||||
1 | 1 | 0 | 1 | 1 | 1 | 1 | 0 | DE |
\(A \longleftarrow A - (HL) - Carry\) | ||||||||
SBC A, (HL) | ||||||||
1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 9E |
\(A \longleftarrow A - (IX+d) - Carry\) | ||||||||
SBC A, (IX+d) | ||||||||
1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | DD |
1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 9E |
d | ||||||||
\(A \longleftarrow A - (IY+d) - Carry\) | ||||||||
SBC A, (IY+d) | ||||||||
1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | FD |
1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 9E |
d | ||||||||
\(A \longleftarrow A - ss - Carry\) | ||||||||
SBC HL, ss | ||||||||
1 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | ED |
0 | 1 | dd | 0 | 0 | 1 | 0 |
Register | r |
---|---|
B | 000 |
C | 001 |
D | 010 |
E | 011 |
H | 100 |
L | 101 |
A | 111 |
Value | dd |
---|---|
00 | BC |
01 | DE |
10 | HL |
11 | SP |
Flags Affected
Flags |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
s | set if result negative | ||||||||
z | set if result is 0 | ||||||||
h | set if borrow from bit 4 | ||||||||
p/v | set if overflow | ||||||||
c | set if borrow |
Opcode Matrix
A | B | C | D | E | H | L | (HL) | (IX+d) | (IY+d) | n | BC | DE | HL | SP | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A |
SBC A,A
9F14 |
SBC A,B
9814 |
SBC A,C
9914 |
SBC A,D
9A14 |
SBC A,E
9B14 |
SBC A,H
9C14 |
SBC A,L
9D14 |
SBC A,(HL)
9E17 |
SBC A,(IX+d)
DD9Enn119 |
SBC A,(IY+d)
FD9Enn119 |
SBC A,n
DEnn27 |
|
|
|
|
HL |
|
|
|
|
|
|
|
|
|
|
|
SBC HL,BC
ED42215 |
SBC HL,DE
ED52215 |
SBC HL,HL
ED62215 |
SBC HL,SP
ED72215 |
Instruction
Opcode hexSize bytesCycle count
| Register | Memory | Implicit |
Last modified November 16, 2021: Add flags to math operations (63d34c2)