SAM47 INSTRUCTION SET KS57C2308/P2308/C2316/P2316
5-80
SBC Subtract With Carry
SBC dst,src
Operation: Operand Operation Summary Bytes Cycles
A,@HL Subtract indirect data memory from A with carry 1 1
EA,RR Subtract register pair (RR) from EA with carry 2 2
RRb,EA Subtract EA from register pair (RRb) with carry 2 2
Description: SBC subtracts the source and carry flag value from the destination operand, leaving the result in
the destination. SBC sets the carry flag if a borrow is needed for the most significant bit;
otherwise it clears the carry flag. The contents of the source are unaffected.
If the carry flag was set before the SBC instruction was executed, a borrow was needed for the
previous step in multiple precision subtraction. In this case, the carry bit is subtracted from the
destination along with the source operand.
Operand Binary Code Operation Notation
A,@HL 00111100C,A A – (HL) – C
EA,RR 11011100C, EA EA –RR – C
11001r2 r1 0
RRb,EA 11011100C,RRb RRb – EA – C
11000r2 r1 0
Examples: 1. The extended accumulator contains the value 0C3H, register pair HL the value 0AAH, and
the carry flag is set to "1":
SCF ;C "1"
SBC EA,HL ;EA 0C3H – 0AAH – 1H, C "0"
JPS XXX ;Jump to XXX; no skip after SBC
2. If the extended accumulator contains the value 0C3H, register pair HL the value 0AAH, and
the carry flag is cleared to "0":
RCF ;C "0"
SBC EA,HL ;EA 0C3H – 0AAH – 0H = 19H, C "0"
JPS XXX ;Jump to XXX; no skip after SBC