zoukankan      html  css  js  c++  java
  • 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.

    1  CMP R5,R6   ; R5 = R6?
    2  JEQ EQUAL   ; YES, JUMP

    Example     Two RAM blocks are compared. If they are not equal, the program branches to the label ERROR.

    1     MOV #NUM,R5       ; number of words to be compared
    2     MOV #BLOCK1,R6    ; BLOCK1 start address in R6
    3     MOV #BLOCK2,R7    ; BLOCK2 start address in R7
    4 L$1 CMP @R6+,0(R7)    ; Are Words equal? R6 increments
    5     JNZ ERROR         ; No, branch to ERROR
    6     INCD R7           ; Increment R7 pointer
    7     DEC R5            ; Are all words compared?
    8     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.

    1 CMP.B EDE,TONI     ; MEM(EDE) = MEM(TONI)?
    2 JEQ EQUAL         ; YES, JUMP
  • 相关阅读:
    CentOS7配置Tomcat8开机自动启动
    StackExchange.Redis 异步超时解决方案
    同一个tomcat部署多个项目导致启动失败
    吐血记录微信小程序授权获取Unionid及linux下使用bouncycastle解密用户数据 遇到的坑
    CentOS7设置ssh服务以及端口修改
    linux CentOS7安装与配置nginx1.18.0 并设置开机启动
    C语言函数指针用法
    Javascript优点和缺点
    VIM 单词大小写转换
    python base64编码实现
  • 原文地址:https://www.cnblogs.com/mengdie/p/4512290.html
Copyright © 2011-2022 走看看