Instruction Set
3-34
RISC 16−Bit CPU
CMP[.W]
Compare source and destination
CMP.B
Compare source and destination
Syntax
CMP
src,dst or
CMP.W
src,dst
CMP.B
src,dst
Operation
dst + .NOT.src + 1
or
(dst − src)
Description
The source operand is subtracted from the destination operand. This is
accomplished by adding the 1s complement of the source operand plus 1. The
two operands are not affected and the result is not stored; only the status bits
are affected.
Status Bits
N: Set if result is negative, reset if positive (src >= dst)
Z: Set if result is zero, reset otherwise (src = dst)
C: Set if there is a carry from the MSB of the result, reset otherwise
V: Set if an arithmetic overflow occurs, otherwise reset
Mode Bits
OSCOFF, CPUOFF, and GIE are not affected.
Example
R5 and R6 are compared. If they are equal, the program continues at the label
EQUAL.
CMP
R5,R6
; R5 = R6?
JEQ
EQUAL
; YES, JUMP
Example
Two RAM blocks are compared. If they are not equal, the program branches
to the label ERROR.
MOV
#NUM,R5
; number of words to be compared
MOV
#BLOCK1,R6
; BLOCK1 start address in R6
MOV
#BLOCK2,R7
; BLOCK2 start address in R7
L$1
CMP
@R6+,0(R7)
; Are Words equal? R6 increments
JNZ
ERROR
; No, branch to ERROR
INCD
R7
; Increment R7 pointer
DEC
R5
; Are all words compared?
JNZ
L$1
; No, another compare
Example
The RAM bytes addressed by EDE and TONI are compared. If they are equal,
the program continues at the label EQUAL.
CMP.B EDE,TONI
; MEM(EDE) = MEM(TONI)?
JEQ
EQUAL
; YES, JUMP
Summary of Contents for MSP430x1xx
Page 1: ... 2005 Mixed Signal Products User s Guide SLAU049E ...
Page 6: ...vi ...
Page 18: ...1 6 Introduction ...
Page 36: ...2 18 System Resets Interrupts and Operating Modes ...
Page 112: ...3 76 ...
Page 130: ...4 18 Basic Clock Module ...
Page 152: ...5 22 Flash Memory Controller ...
Page 160: ...6 8 Supply Voltage Supervisor ...
Page 168: ...7 8 Hardware Multiplier ...
Page 192: ...8 24 ...
Page 200: ...9 8 Digital I O ...
Page 234: ...11 24 Timer_A ...
Page 260: ...12 26 Timer_B ...
Page 291: ...13 31 USART Peripheral Interface UART Mode ...
Page 314: ...14 23 USART Peripheral Interface SPI Mode ...
Page 346: ...15 32 USART Peripheral Interface I2C Mode ...
Page 358: ...16 12 Comparator_A ...
Page 386: ...17 28 ADC12 ...
Page 418: ...18 32 ADC10 ...
Page 432: ...19 14 DAC12 ...