汇编语言(三十五)之输入字符串以$结束然后输出字母个数
输入字符串以$结束然后输出字母个数
程序运行:
代码:
datas segment
buff db 100h dup(?)
letter_count dw 0
nextline db 0dh,0ah,'$'
datas ends
codes segment
assume cs:codes,ds:datas
main proc far
push ds
mov ax,0
push ax
mov ax,datas
mov ds,ax
s:
mov ah,1
int 21h
cmp al,'$'
jz break
mov buff,al
and al,11011111b
cmp al,'A'
jb next
cmp al,'Z'
ja next
inc letter_count
next:
jmp s
break:
lea dx,nextline
mov ah,9
int 21h
mov ax,letter_count
call todecimal
ret
main endp
todecimal proc near uses ax bx cx dx
mov bx,10
mov cx,0
s:
mov dx,0
div bx
push dx
inc cx
or ax,ax
jnz s
s1:
pop dx
add dl,30h
mov ah,2
int 21h
loop s1
ret
todecimal endp
codes ends
end main