MSP430之instruction之CMP

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.

1  CMP R5,R6   ; R5 = R6?
2  JEQ EQUAL   ; YES, JUMP

Example     Two RAM blocks are compared. If they are not equal, the program branches to the label ERROR.

1     MOV #NUM,R5       ; number of words to be compared
2     MOV #BLOCK1,R6    ; BLOCK1 start address in R6
3     MOV #BLOCK2,R7    ; BLOCK2 start address in R7
4 L$1 CMP @R6+,0(R7)    ; Are Words equal? R6 increments
5     JNZ ERROR         ; No, branch to ERROR
6     INCD R7           ; Increment R7 pointer
7     DEC R5            ; Are all words compared?
8     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.

1 CMP.B EDE,TONI     ; MEM(EDE) = MEM(TONI)?
2 JEQ EQUAL         ; YES, JUMP
时间: 2024-10-07 22:52:19

MSP430之instruction之CMP的相关文章

MSP430之instruction之JUMP

JMP  Jump unconditionally Syntax   JMP  label Operation PC + 2 × offset −> PC Description The 10-bit signed offset contained in the instruction LSBs is added to the program counter. Status Bits Status bits are not affected. Hint: This one-word instru

MSP430之instruction之Indirect Autoincrement Mode

Assembler Code Content of ROMMOV @R10+,0(R11)   MOV @R10+,0(R11) Length: One or two words Operation: Move the contents of the source address (contents of R10) to the destination address (contents of R11). Register R10 is incremented by 1 for a byte o

MSP430之instruction之MOV

MOV[.W]   Move source to destinationMOV.B Move source to destination Syntax MOV  src,dst  or       MOV.W  src,dst MOV.B src,dst Operation src −> dst Description The source operand is moved to the destination.The source operand is not affected. The pr

Assembly之instruction之JC

JC Jump if carry setJHS  Jump if higher or same Syntax JC label JHS label Operation If C = 1: PC + 2 × offset −> PC If C = 0: execute following instruction Description The status register carry bit (C) is tested. If it is set, the 10-bit signed offse

关于EJB--实体Bean的BMP和CMP选择

EJB有两种主要类型BMP(Bean managed persistence )和CMP(Container managed persistence ),这两种类型各有优缺点. BMP是在Bean中完成对数据库JDBC的各种调用,也就是说,在你的实体bean(entity bean)中,明确写入了SQL语句,如"insert .. "或"select ..",并且使用Datasource获得一个数据库资源以及连接(connection)从而对数据库直接进行增加删除修

C/C++ 调用qsort/sort 对字符数组排序的cmp函数写法

这个问题屡次碰到解决之后再次遇到又忘记怎么弄了,这次打算彻底搞清楚. ·C 首先对所谓字符数组的排序应该是对(char)*a[]数组而非(char)a[][]进行的排序,后者是无法直接调用qsort实现其排序的. cmp函数写法: 1 int cmp(const void *a, const void *b){ 2 return strcmp(*((char**)a), *((char**)b)); 3 } 很容易想象字符串在初始化时已经被分配了特定的存储空间,我们用其首地址标识该字符串. 对于

【Linux命令-文件管理类】cmp命令

cmp(compare)命令 命令作用:比较两个文件之间的差异 命令用法:cmp [-clsv][-i <字符数目>][–help][第一个文件][第二个文件] 当相互比较的两个文件完全一样时,则该指令不会显示任何信息: 若发现有所差异,预设会标示出第一个不同之处的字符和列数编号: 若不指定任何文件名称或是所给予的文件名为"-",则cmp指令会从标准输入设备读取数据. 命令参数: -c或–print-chars 除了标明差异处的十进制字码之外,一并显示该字符所对应字符. -

openMSP430之instruction

Byte and word issues 1 Appending “.b” to an instruction makes it a byte operation. A byte instruction with a register destination clears the high 8 bits of the register to 0. Thus, the following would clear the top byte of the register, leaving the l

Instruction (hdu 5083)

Instruction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 163    Accepted Submission(s): 46 Problem Description Nowadays, Jim Green has produced a kind of computer called JG. In his computer,