[汇编实验:循环程序&子程序练习]
实验要求
编程统计100字数组array中最低6位全为1的数的个数,将个数放在寄存器bx中,并以十六进制形式显示个数,然后统计array中第0、2、4、6位全为1的数的个数,将个数放在寄存器bx中,并以十六进制形式显示个数。统计功能分别用子程序count1和count2实现,十六进制显示用子程序binihex实现。已知数据段内容如下:
data segment
array dw 003fh, 00fah, 0, 006fh, 0ff00h, 0ff7fh, 47 dup(55, 0aah)
data ends
代码
;字符串输出
display macro message
push dx
push ax
lea dx,message
mov ah,9
int 21h
pop ax
pop dx
endm
;回车换行
crlf macro
push dx
push ax
mov dl,0dh
mov ah,2
i
nt 21h
mov dl,0ah
int 21h
pop ax
pop dx
endm
DATAS SEGMENT
array dw 003fh, 00fah, 0, 006fh, 0ff00h, 0ff7fh, 47 dup(55h, 0aah)
mess1 db "The amount of count1 number is:$"
mess2 db "The amount of count1 number is:$"
DATAS ENDS
CODES SEGMENT
main proc far
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
call count1
display mess1