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#学习笔记_08_面向对象
08_面向对象 面向对象:一种看待问题解决问题的思维方式,着眼点在于找到一个能够帮助我们解决问题的实体,然后委托这个实体来帮我们解决问题:(在面向对象之前你要有一个女朋友,否则代码会经常出现bug) ...
- 学习C语言偶遇【斐波那契数列】
1.今天学着学着就发现一个特别有趣的数列,斐波那契数列,感觉很好玩,翠花,上代码~~~~~~~ #include <stdio.h> int fibonaci(int i) { ) { ; ...
- 如何让其他计算机访问我的计算机上mysql数据库?
先判断是不是在同 一个网络之间,你ping 一下它的ip ,看能不能ping通. 这样就有两种情况, 第一种:能ping通,说明你们在同一个网络中,可以直接访问.你只要在你的登录用户中的帐号加上可外部 ...
- 手机版地图api
手机版地图api一: <iframe style="height:300px;" src="http://map.baidu.com/mobile/webapp/s ...
- 简单的SpringBoot环境搭建
开始搭建前请确认您的计算机中的Maven已正确配置 一:使用IDEA创建一个Maven项目,图中第一个指针请选择自己正在使用的JDK版本,指针二请打勾,选中指针三所指向的类型并点击Next 二:填写G ...
- hdu2005 第几天?【C++】
第几天? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- 多层gmetad配置
经实验表明: ①多层gmetad与ganglia版本无关,且可以多版本兼容 ②多层gmetad只有最底层gmetad能保存详细指标,非底层gmetad收集到的都只能是summary信息,当然也许我配置 ...
- mbr gpt
超过2T硬盘的磁盘要用gpt格式,准确地说,应该是分区超过2T地硬盘要选用GPT模式. 做个小推广:程序员经常久坐,颈椎毛病比较多,特别推荐ventry颈椎保健枕
- 利用Calendar类测试电脑运行速度
今天学习了很多新知识! 这里使用了Calender类来获取系统时间,并计算循环1w次的时间,判断电脑处理时间. import java.util.Calendar; public class Arra ...
- N天学习一个linux命令之ssh
用途 通过加密连接,远程登录主机和在远程主机执行命令,也可以用于转发x11和tcp,也可用于搭建VPN.第一次连接时,会弹出远程主机公钥指纹确认信息,通过这个方式防止中间人攻击. 用法 ssh [op ...