8086指令系统---逻辑指令
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 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
8086指令系统逻辑指 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)