Assembly之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.
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的更多相关文章
- Assembly之instruction之JC
JC Jump if carry setJHS Jump if higher or same Syntax JC label JHS label Operation If C = 1: PC + 2 ...
- Assembly之instruction之JUMP
JMP Jump unconditionally Syntax JMP label Operation PC + 2 × offset −> PC Description The 10- ...
- Assembly之instruction之Indirect Autoincrement Mode
Assembler Code Content of ROMMOV @R10+,0(R11) MOV @R10+,0(R11) Length: One or two words Operation: ...
- Assembly之Instruction之Byte and Word
Byte and word issues The MSP430 is byte-addressed, and little-endian. Word operands must be located ...
- Assembly之instruction之Status register
The status register (SR/R2), used as a source or destination register, can be used in the register m ...
- Assembly之instruction之Register Mode
Assembler Code Content of ROM MOV R10,R11 MOV R10,R11 Length: One or two words Operation: Move the c ...
- Assembly之instruction之MOV
MOV[.W] Move source to destinationMOV.B Move source to destination Syntax MOV src,dst or M ...
- [转]LLVM MC Project
Intro to the LLVM MC Project The LLVM Machine Code (aka MC) sub-project of LLVM was created to solve ...
- BitHacks
备份文件时看到的.我以前居然下过这东西. 2016-12-4 12:05:52更新 纯文本格式真棒.假如使用word写的我能拷过来格式还不乱?? Markdown真好. Bit Hacks By Se ...
随机推荐
- C#学习笔记_11_方法的隐藏和重写
11_方法的隐藏和重写 方法的隐藏 需要使用到关键字:new 方法的重写 虚函数: 使用关键字virtual修饰的函数 虚函数可以被子类隐藏,也可以被子类重写 非虚函数只能被子类隐藏 关键字:over ...
- vue轮播插件vue-awesome-swiper
https://surmon-china.github.io/vue-awesome-swiper/ 第一步安装 npm install vue-awesome-swiper --save 第二部在m ...
- linux学习7-数据流重定向
数据流重定向 实验介绍 你可能对重定向这个概念感到些许陌生,但你应该在前面的课程中多次见过>或>>操作了,并知道他们分别是将标准输出导向一个文件或追加到一个文件中.这其实就是重定向, ...
- FOJ2250 不可能弹幕结界
Problem 2250 不可能弹幕结界 Time Limit: 1000 mSec Memory Limit : 65536 KB Problem Description 咲夜需要穿过一片弹幕 ...
- 清北学堂模拟赛d6t4 数组异或
分析:直接O(n^3)做是只有50分的,可以加一点小小的优化,就是c[k]可以从c[k-1]得到,但是还是只有60分,从宏观意义上是不能继续优化了.对于这类涉及到位运算的性质的题目,将每个数转化成二进 ...
- Linux - Virsh
virsh命令 suspend resume dumpxml KVM平台以存储池的形式对存储进行统一管理,所谓存储池能够理解为本地文件夹.通过远端磁盘阵列(iSCSI.NFS)分配过来磁盘或文件夹 ...
- web端log4net输出错误日志到mysql
1.引用log4net 2.配置log4net.config文件 <?xml version="1.0" encoding="utf-8" ?> & ...
- hdu1542 线段树+扫描线+离散化
仅仅想说题目给的欲实际不服 还是这类型的水题吧 建议看之前我写的那个 #include<stdio.h> #include<string.h> #include&l ...
- opencv源代码分析之二:cvhaartraining.cpp
我使用的是opencv2.4.9.安装后.我的cvboost..cpp文件的路径是........\opencv\sources\apps\haartraining\cvhaartraining.cp ...
- Ambarella SDK build 步骤解析
Make Target Options make命令如下: make <Tab> <Tab> /*列出所有支持的目标(命令行输入make, 再按两下Tab键)*/ make & ...