3 INSTRUCTION SET

CP r,i

Compare immediate data i with r-register

Source Format:

CP

r,i

 

Operation:

r - i3 to i0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

OP-Code:

 

1

 

1

0

1

1

1

r1

r0

i3

i2

i1

i0

DC0H to DFFH

 

MSB

 

 

 

 

 

 

 

 

 

 

LSB

 

Type:

II

 

 

 

 

 

 

 

 

 

 

 

 

Clock Cycles:

7

 

 

 

 

 

 

 

 

 

 

 

 

 

Flag:

 

C – Set if r < i3 to i0; otherwise, reset.

 

 

 

Z – Set if r = i3 to i0; otherwise, reset.

 

 

 

D – Not affected

 

 

 

I – Not affected

 

Description: Compares immediate data i to the r-register by subtracting i from the contents of r. The r-register remains unchanged.

1.When Z = 0 and C = 0 then i < r2.When Z = 1 and C = 0 then i = r3.When Z = 0 and C = 1 then i > r

Example:

 

CP A,4

 

 

CP MX,7

 

CP B,2

 

A register

0100

 

0100

 

0100

 

0100

 

B register

1010

 

1010

 

1010

 

1010

 

Memory (MX)

0010

 

0010

 

0010

 

0010

 

C flag

1

 

0

 

1

 

0

 

Z flag

0

 

1

 

0

 

0

 

 

 

 

 

 

 

 

 

 

 

CP r,q

Compare q-register with r-register

 

Source Format:

CP r,q

 

 

 

Operation:

r - q

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

OP-Code:

 

1

 

1

1

1

0

0

0

0

r1

r0

q1

q0

F00H to F0FH

 

MSB

 

LSB

 

Type:

IV

 

 

 

 

 

 

 

 

 

 

 

 

 

Clock Cycles:

7

 

 

 

 

 

 

 

 

 

 

 

 

 

Flag:

 

C – Set if r < q; otherwise, reset.

 

 

 

 

 

Z – Set if r = q; otherwise, reset.

 

 

 

 

 

D – Not affected

 

 

 

 

 

I

– Not affected

 

 

 

Description:

Compares the q-register to the r-register by subtracting the contents of q from the

 

contents of r. The registers remain unchanged.
1.When Z = 0 and C = 0 then q < r2.When Z = 1 and C = 0 then q = r3.When Z = 0 and C = 1 then q > r

Example:

 

CP A,B

 

 

CP MY,A

 

A register

1000

 

1000

 

1000

 

B register

0100

 

0100

 

0100

 

Memory (MY)

0111

 

0111

 

0111

 

C flag

0

 

0

 

1

 

Z flag

0

 

0

 

0

S1C6200/6200A CORE CPU MANUAL

EPSON

35