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. Linux - redis主从同步

    目录 Linux - redis主从同步 环境准备 配置主从同步 测试写入数据,主库写入数据,检查从库数据 手动进行主从复制故障切换 Linux - redis主从同步 原理: 从服务器向主服务器发送 ...

  2. Django - 日志工作中常用配置

    工作中常用配置 # 日志配置 BASE_LOG_DIR = os.path.join(BASE_DIR, "log") LOGGING = { 'version': 1, # 保留 ...

  3. TypeError: CleanWebpackPlugin is not a constructor

    在项目中引入clean-webpack-plugin打包后报错 new CleanWebpackPlugin(), ^ TypeError: CleanWebpackPlugin is not a c ...

  4. fastclick:处理移动端click事件300毫秒延迟

    fastclick:处理移动端click事件300毫秒延迟 1.兼容性 iOS 3及更高版本的移动Safari iOS 5及更高版本的Chrome Android上的Chrome(ICS) Opera ...

  5. zookeeper概念与原理

    ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,它包含一个简单的原语集,分布式应用程序可以基于它实现同步服务,配置维护和命名服务等. 1 Zookeeper的基本概念 1.1 角色 ...

  6. maven local responsitory 手工新增jar

    1.推荐几个好的 Maven 常用仓库网址:http://mvnrepository.com/http://search.maven.org/http://repository.sonatype.or ...

  7. [bzoj1040][ZJOI2008]骑士_树形dp_基环树_并查集

    骑士 bzoj-1040 ZJOI-2008 题目大意:n个骑士,每个骑士有权值val和一个讨厌的骑士.如果一个骑士讨厌另一个骑士那么他们将不会一起出战.问出战的骑士最大atk是多少. 注释:$1\l ...

  8. Oracle数据库点滴

    分页查询: SELECT * FROM (SELECT A.*, ROWNUM RN FROM (SELECT * FROM TABLE_NAME) A WHERE ROWNUM <= 40)W ...

  9. Android Notification状态栏通知

    没有添加额外的震动及声音效果,这里直接实现了通知的功能,看效果吧: MainActivity.java package com.example.notification; import android ...

  10. Hadoop - YARN 启动流程

       一  YARN的启动流程                                                                 watermark/2/text/aHR ...