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+,(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

Assembly之instruction之CMP的更多相关文章

  1. Assembly之instruction之JC

    JC Jump if carry setJHS  Jump if higher or same Syntax JC label JHS label Operation If C = 1: PC + 2 ...

  2. Assembly之instruction之JUMP

    JMP  Jump unconditionally Syntax   JMP  label Operation PC + 2 × offset −> PC Description The 10- ...

  3. Assembly之instruction之Indirect Autoincrement Mode

    Assembler Code Content of ROMMOV @R10+,0(R11)   MOV @R10+,0(R11) Length: One or two words Operation: ...

  4. Assembly之Instruction之Byte and Word

    Byte and word issues The MSP430 is byte-addressed, and little-endian. Word operands must be located ...

  5. Assembly之instruction之Status register

    The status register (SR/R2), used as a source or destination register, can be used in the register m ...

  6. Assembly之instruction之Register Mode

    Assembler Code Content of ROM MOV R10,R11 MOV R10,R11 Length: One or two words Operation: Move the c ...

  7. Assembly之instruction之MOV

    MOV[.W]   Move source to destinationMOV.B Move source to destination Syntax MOV  src,dst  or       M ...

  8. [转]LLVM MC Project

    Intro to the LLVM MC Project The LLVM Machine Code (aka MC) sub-project of LLVM was created to solve ...

  9. BitHacks

    备份文件时看到的.我以前居然下过这东西. 2016-12-4 12:05:52更新 纯文本格式真棒.假如使用word写的我能拷过来格式还不乱?? Markdown真好. Bit Hacks By Se ...

随机推荐

  1. [HDU3038]How Many Answers Are Wrong(并查集)

    传送门 和某题类似,只不过奇偶换成了和. ——代码 #include <cstdio> #include <iostream> #define N 1000001 int n, ...

  2. java中静态资源处理方法

    方案一:激活Tomcat的defaultServlet来处理静态文件 在 web.xml 中添加: <servlet-mapping> <servlet-name>defaul ...

  3. Myeclipse10完美破解过程

    Myeclipse10完美破解过程 1.假设还没有破解文件的话,能够先到这里去下载破解件 http://download.csdn.net/download/wangcunhuazi/7874155 ...

  4. HDU 4362

    方程很简单 p[i][j] = min{dp[i-1][k] + |pos[i-1][k] - pos[i][k]|} + v[i][j]; 循环求值肯定TLE,主要是绝对值不方便.好吧,我真的BI了 ...

  5. HDU 4360

    题意很好理解. 由于点是可以重复到达的,但可能每次经过路径的标志不一样,所以可以设每个点有四种状态"L”,'O','V','E'.然后按这些状态进行求最短路,当然是SPFA了. #inclu ...

  6. linux 获取经过N层Nginx转发的访问来源真实IP

    linux 获取经过N层Nginx转发的访问来源真实IP 学习:http://blog.csdn.net/zhenzhendeblog/article/details/49702575 学习:http ...

  7. VMware Workstation 集群仲裁磁盘和数据共享磁盘的创建

    近期项目须要对SQL Server建立集群服务,多个SQL Server数据库建立集群服务,对外提供唯一的URL訪问地址.当主节点断电.断网后,通过心跳线将消息传递到备用节点.备用节点在3秒内接管数据 ...

  8. oc51--循环retain

    // main.m // 循环retain #import <Foundation/Foundation.h> #import "Person.h" #import & ...

  9. 深入理解Android开发中的CoordinatorLayout Behavior

    在使用Android设计支持库(Android Design Support Library)时,很难避开CoordinatorLayout:设计库中有很多视图都需要CoordinatorLayout ...

  10. Android+Jquery Mobile学习系列(4)-页面转场及参数传递

    关于页面转场,这个必须得专门列出来说明一下,因为Jquery Mobile与普通的Web发开有一些区别,这个对于新手如果不了解的话,就会钻到死胡同.撸主前段时间就是很急躁地上手开发程序,结果在页面转场 ...