SAM47 INSTRUCTION SETKS57C2308/P2308/C2316/P2316

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

0

0

1

 

1

1

 

1

0

0

C,A A – (HL) – C

 

 

 

 

 

 

 

 

 

 

 

 

EA,RR

1

1

0

 

1

1

 

1

0

0

C, EA EA –RR – C

 

 

 

 

 

 

 

 

 

 

 

 

 

1

1

0

 

0

1

 

r2

r1

0

 

 

 

 

 

 

 

 

 

 

 

 

 

RRb,EA

1

1

0

 

1

1

 

1

0

0

C,RRb RRb – EA – C

 

 

 

 

 

 

 

 

 

 

 

 

 

1

1

0

 

0

0

 

r2

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

5-80

Page 154
Image 154
Samsung KS57C2308 manual SBC Subtract With Carry, Scf Sbc Ea,Hl, Rcf Sbc Ea,Hl