CMP

Comparison

CMP

CoMPare


[Syntax]

CMP src, src2

 

[Operation]

src2 - src;

 

[Function]

-

This instruction changes the states of flags in the PSW to reflect the result of subtracting src from src2.

 

[Instruction Format]

Syntax

Processng Size

src

src2

Code size

(Byte)

CMP src, src2s

L

#UIMM:4

Rs

2

L

#UIMM:8(Notes 1.)

Rs

3

L

#SIMM:8(Notes 1.)

Rs

3

L

#SIMM:16

Rs

4

L

#SIMM:24

Rs

5

L

#IMM:32

Rs

6

L

Rs

Rs2

2

L

[Rs].memex

Rs2

2(memex == UB)

3(memex != UB)

L

dsp:8[Rs].memex

Rs2

3(memex == UB)

4(memex != UB)

L

dsp:16[Rs].memex

Rs2

4(memex == UB)

5(memex == UB)

[Flag Change]

Flag

C

Z

S

O

Change

 

 

 

 

Conditions

C : The flag is set if an unsigned operation does not produce an overflow; otherwise it is cleared.

Z : The flag is set if the result of the operation is 0; otherwise it is cleared.

S : The flag is set if the MSB of the result of the operation is 1; otherwise it is cleared.

O : The flag is set if a signed operation produces an overflow; otherwise it is cleared.

 

[Description Example]

CMP #7, R2

CMP R1, R2

CMP [R1], R2