微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 8086指令系统---逻辑指令

8086指令系统---逻辑指令

时间:11-27 来源:互联网 点击:

例写DATA1除以8的程序,假设:⑴DATA1为无符号数⑵DATA1为带符号数。

      DATA1  DB   9AH
      TIMES  EQU   3

      ; ⑴ DATA1 is unsigned operand
         MOV   CL,TIMES   ; set number of times to shift
         SHR    DATA1,CL   ; DATA1 will be 13H, CF=0
         
       ; ⑵ DATA1 is signed operand
         MOV    CL,TIMES   ; set number of times to shift
         SAR    DATA1, CL   ; DATA1 will be 0F3H, CF=0

例编写统计DATAW字数据中1的个数COUNT的程序,要求COUNT是BCD码。
  
      DATAW  DW   97F4H
      COUNT  DB   ?
      …    …
       XOR   AL,AL   ; clear AL to keep the number of 1s in BCD
       MOV   DL,16   ; rotate total of 16 times
       MOV   BX,DATAW ; move the operand to BX
    AGAIN: ROL   BX,1    ; rotate it once
       JNC   NEXT   ; check for 1, if CF=0 then jump
       ADD   AL,1   ; if CF=1 then add one to count
       DAA        ; adjust the count for BCD
    NEXT: DEC   DL     ; go through this 16 times
        JNC   AGAIN   ; if not finished go back
       MOV   COUNT,AL ; save the number of 1s in COUNT

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top