Cp — Compare - Samsung S3F84B8 User Manual

8-bit cmos
Hide thumbs Also See for S3F84B8:
Table of Contents

Advertisement

S3F84B8_UM_REV 1.00
6.3.17 CP — COMPARE
dst,src
CP
dst – src
Operation:
The source operand is compared to (subtracted from) the destination operand, and the
appropriate flags are set accordingly. The contents of both operands remain unaffected by the
comparison.
C: Set if a "borrow" occurred (src > dst); cleared otherwise.
Flags:
Z: Set if the result is "0"; cleared otherwise.
S: Set if the result is negative; cleared otherwise.
V: Set if arithmetic overflow occurred; cleared otherwise.
D: Unaffected.
H: Unaffected.
Format:
opc
opc
opc
1.
Examples:
The destination working register R1 contains the value 02H and source register R2 contains the
value 03H. The statement "CP R1,R2" subtracts R2 value (source/subtrahend) from R1 value
(destination/minuend). When "borrow" occurs and the difference is negative, C and S are "1".
2.
In this example, the destination working register R1 contains the value 05H, which is less than the
contents of source working register R2 (0AH). The statement "CP R1,R2" generates C = "1" and
the JP instruction does not jump to SKIP location. Once the statement "LD R3,R1" is executed,
the value 06H remains in working register R3.
dst | src
src
dst
dst
src
Given R1 = 02H and R2 = 03H:
R1,R2 
CP
Given R1 = 05H and R2 = 0AH:
CP
R1,R2
JP
UGE,SKIP
INC
R1
SKIP
LD
R3,R1
Bytes
2
3
3
Set the C and S flags
6-29
6 INSTRUCTION SET
Cycles
Opcode
(Hex)
4
A2
6
A3
6
A4
6
A5
6
A6
Addr Mode
dst
src
r
r
r
lr
R
R
R
IR
R
IM

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents