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. 【codeforces 509A】Maximum in Table

    [题目链接]:http://codeforces.com/contest/509/problem/A [题意] 给你一个递推式f[i][j] = f[i-1][j]+f[i][j-1]; 让你求f[i ...

  2. 同开三本DJANGO,需要提升一下本职工作的能力啦

    慢慢将一些概念固化到基因内,才有可能和SPRING MVC,MEAN之类的好好作比较吧. 全都是基于1.8版本的教材,爽!!!

  3. SpringMVC项目

    一.说明该项目是为了演示SpringMVC框架中涉及到的一些知识点,相对独立,掌握这些,基本上就能够解决工作中遇到的一些问题.整个项目的构建规划如下: 1.创建一个标准的Maven Web项目;2.使 ...

  4. HDU 4519

    实现简单,但不得不说是一道好题. 当员工数少于医生数时,直接输出K,因为此时N个员工同时检查,必定是最少的时间了. 当员工数大于医生数时,可以把员工的项目看成一段一段的,每个医生对其进行切割,总能得到 ...

  5. ACdream区域赛指导赛之专题赛系列(1)の数学专场

    Contest : ACdream区域赛指导赛之专题赛系列(1)の数学专场 A:EOF女神的相反数 题意:n(<=10^18)的数转化成2进制.翻转后(去掉前导零)输出十进制 思路:water ...

  6. 一起talk C栗子吧(第七十七回:C语言实例--DIY ls命令续)

    各位看官们,大家好.上一回中咱们说的是DIY cat命令的样例.这一回咱们说的样例是:DIY ls命令续. 闲话休提,言归正转.让我们一起talk C栗子吧! 我们在前面的章回中DIY过ls命令.时间 ...

  7. iOS分组通讯录效果+側滑菜单(MMDrawerController)

    前言的废话-能够忽略 自从学会了使用Cocoapod,就欲罢不能了!由于太简单太赞了,不用再把源代码粘到project里了! 參见戴维营博客中的解说:Cocoapod 安装以及使用 先上一下效果图,请 ...

  8. 寒城攻略:Listo 教你用 Swift 写IOS UI 项目计算器

    之前总结过 Swift 的语言攻略,这里就不做赘述了,如今做一个实例计算器项目来介绍一下 Swift 的应用.(凝视已经全然.直接上代码) 先看一下效果图: 以下是详细的代码和解释: 分享快乐.开源中 ...

  9. 605B. Lazy Student(codeforces Round 335)

    B. Lazy Student time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  10. 【第7篇】TypeScript泛型的案例代码具体解释

    8.1最简单泛型样例 Ts代码 /** * 没有泛型,我们要么必须给身份功能的特定类型 */ function identity1(arg: number): number { return arg; ...