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 ...
随机推荐
- axios请求中跨域及post请求问题解决方案
闲话不多说,用到vue的童鞋们应该大部分都会遇到请求中的各种奇葩问题,昨天研究一天,终于搞出来个所以然了,写篇文章拯救一下广大的童鞋们,某度娘当然也可以搜到,但一般解决了一个问题后就会出现另外一个问题 ...
- Selenium的安装和简单实用——PhantomJS安装
简介 Selenium是一个用于Web应用程序测试的工具. Selenium测试直接运行在浏览器中,就像真正的用户在操作一样.支持的浏览器包括IE(7, 8, 9, 10, 11),Firefox,S ...
- Master Nginx(6) - The Nginx HTTP Server
Nginx's architecture The HTTP core module The server Logging Finding files Name resolution Client in ...
- nyoj_60_谁获得了最高奖学金_201311281117
谁获得了最高奖学金 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 某校的惯例是在每学期的期末考试之后发放奖学金.发放的奖学金共有五种,获取 ...
- [poj1363]Rails_模拟_栈
Rails poj-1363 题目大意:判断一个序列是否是1~n的合法出栈序列. 注释:$1\le n\le 10^4$. 想法:开始想到一种想法. 对于一段序列来讲,显然从首元素开始的连续小于尾元素 ...
- 一个神奇的PHP框架:Phalcon 之初识
前言 公司的APP响应速度比较慢,公司大神决定使用C语言编写的PHP框架Phalcon 代替原来的框架,响应速度有比较大的提升.以前只是听说过,没有深入的了解过.即然工作中有用到,便花点时间了解了下, ...
- Adobe photoshop CC 2018安装激活教程
2017年10月,Adobe公司发布最新版Adobe CC 2018系列软件,photoshop cc 2018更是迎来惊艳的新功能.下面来分享安装和激活教程. 不会安装请加QQ:1833920353 ...
- 微信推送给服务器的XML消息解析-springmvc 解析xml数据流
微信推送给服务器的XML消息解析: 可以使用request.getInputStream(); 获取输入的消息流:但是需要自己解析流: spring mvc自带解析功能: controller中: @ ...
- 【Anroid界面实现】WindowManager类使用具体解释——用户首次打开APP的使用教学蒙板效果实现
转载请注明出处:http://blog.csdn.net/zhaokaiqiang1992 在上一篇的文章中,我们介绍了怎样实现桌面悬浮窗体,在这个效果的实现过程中.最重要的一个类就是WindowMa ...
- umask函数的使用方法 - 怎样进行权限位的设置
以下程序创建了两个文件,创建foo文件时,umask值为0,创建第二个时,umask值禁止全部组和其它用户的訪问权限. 測试结果: 測试结果能够看出更改进程的文件模式掩码并不影响其父进程(经常是she ...