汇编 从键盘上输入一系列以$为结束符的字符串,然后对其中的非数字字符计数,并显示出计数结果

2024-11-30 17:30:13
推荐回答(1个)
回答1:

.model small
.data
BUF DB 'asdf12JKL;$'
NUMBER DB 0
BIGGER DB 0
SMALLER DB 0
.code
START:MOV AX,@data
MOV DS,AX
lea SI,buf
cld
CHECK:LODSB
CMP AL,'$'
JZ DONE
CMP AL,30H
JB NEXT
CMP AL,39H
JNA NUM
CMP AL,40H
JNA NEXT
CMP AL,5AH
JNA BIG
CMP AL,60H
JNA NEXT
CMP AL,7AH
JNA SMA
JMP NEXT
NUM:INC NUMBER
JMP NEXT
BIG:INC BIGGER
JMP NEXT
SMA:INC SMALLER
NEXT:jmp CHECK
done:
.exit
end start