.MODEL SMALL
.DATA
STRING1 DB 'PLEASE ENTER ONE SENTENCE$';
STRING2 DB 'THE RESULT:$';
num db 53 dup(?)
.CODE
main proc far
mov ax,@data
mov ds,ax
call init
call read
call output
main endp
init proc near
mov cx,53
mov bx,0
init1:
mov num[bx],0
inc bx
loop init1
ret
init endp
;------------------------------
read proc near
lea dx,STRING1
mov ah,09h
int 21h
read2:
mov ah,01h
int 21h
cmp al,0dh
je exit
sub al,40h
cmp al,1bh
jl read1
sub al,5
read1:
cbw
mov bx,ax
inc num[bx]
jmp read2
exit:
ret
read endp
;------------------------------
output proc near
lea dx,STRING2
mov ah,09h
int 21h
mov bx,1
output1:
inc bx
cmp bx,53
je exit
cmp num[bx],0
je output1
cmp bx,27
jg output2
mov ax,bx
add ax,40h
mov dl,al
mov ah,02h
int 21h
jmp output3
output2:
mov ax,bx
add ax,45h
mov dl,al
mov ah,02h
int 21h
output3:
mov si,0
mov al,num[bx]
cbw
output4:
mov dx,0
mov cx,10
div cx
add dx,30h
push dx
inc si
cwd
cmp ax,0
je output5
jmp output4
output5:
pop ax
dec si
mov dl,al
mov ah,02h
int 21h
cmp si,0
jne output5
mov dl,' '
mov ah,02h
int 21h
jmp output1
exit:
ret
output endp
ENDING:
MOV AX,4C00H; 终止程序
INT 21H
END
汇编语言:一段英文中各字母的个数
猜你喜欢
转载自blog.csdn.net/weixin_43698704/article/details/84679865
今日推荐
周排行