2 li222881 li222881 于 2016.03.08 13:00 提问

汇编语言,随机输入字符串分类输出并统计个数。下面代码只能统计个数,怎么把字符分类输出?

DATAS SEGMENT
letter db 0
digit db 0
other db 0
str db 80,?,80 dup(?)
str2 db 'letter:$'
str3 db 'digit:$'
str4 db 'other:$'
DATAS ENDS

CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
lea dx,str
mov ah,0ah
int 21h
mov ch,0
mov cl,80
L1:mov ah,1
int 21h
cmp al,0dh
jz over
cmp al,'0'
jb others
cmp al,'9'
ja L2
jmp digits
L2:cmp al,'A'
jb others
cmp al,'Z'
ja L3
jmp letters
L3:cmp al,'a'
jb others
cmp al,'z'
ja others
jmp letters
letters:
inc letter
jmp over1
digits:
inc digit
jmp over1
others:
inc other
jmp over
over1:
loop L1
over:
call endline
lea dx,str2
mov ah,9
int 21h
sub ax,ax
mov al,letter
call display
call endline
lea dx,str3
mov ah,9
int 21h
sub ax,ax
mov al,digit
call display
call endline
lea dx,str4
mov ah,9
int 21h
sub ax,ax
mov al,other
call display
MOV AH,4CH
INT 21H
endline proc near
mov ah,2
mov dl,0ah
int 21h
mov ah,2
mov dl,0dh
int 21h
ret
endline endp
display proc near
mov dl,al
add dl,30h
mov ah,2
int 21h
ret
display endp

CODES ENDS
END START

1个回答

devmiao
devmiao   Ds   Rxr 2016.03.08 13:01
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!