您的位置:首页 > 其它

从键盘输入一系列字符(以回车符结束),并按字母、数字及其他字符分类计数,最后显示出这三类的计数结果

2007-11-24 10:47 2711 查看
;从键盘输入一系列字符(以回车符结束),并按字母、数字及其他字符分类计数,最后
;显示出这三类的计数结果
;create date:2007-11-23
;author:野渡无人
;**************************************************************************
data segment
count_of_letter db 'the number of letter is :','$'
count_of_number db 'the number of number is :','$'
count_of_character db 'the number of character is :','$'
data ends
;**************************************************************************
prognam segment
;--------------------------------------------------------------------------
main proc far
assume cs:prognam,ds:data

start:
push ds
sub ax,ax
push ax

mov ax,data
mov ds,ax

mov bh,0 ;count_of_letter
mov bl,0 ;cout_of_number
mov cl,0 ;cout_of_charater

next:
mov ah,1
int 21h

cmp al,0dh
je exit

cmp al,30h
jb cout_of_charater_add

cmp al,39h
jbe cout_of_number_add

cmp al,41h
jb cout_of_charater_add

cmp al,5ah
jbe count_of_letter_add

cmp al,61h
jb cout_of_charater_add

cmp al,7ah
jbe count_of_letter_add

cout_of_charater_add:
inc cl
jmp next

cout_of_number_add:
inc bl
jmp next

count_of_letter_add:
inc bh
jmp next

exit:
call crlf

lea dx,count_of_letter
mov ah,09
int 21h

mov al,bh
call bin_dec

; mov ah,02h
; mov dl,bh
; int 21h

call crlf

lea dx,count_of_number
mov ah,09
int 21h

mov al,bl
call bin_dec

; mov ah,02h
; mov dl,bl
; int 21h

call crlf

lea dx,count_of_character
mov ah,09
int 21h

mov al,cl
call bin_dec

;mov ah,02h
;mov dl,cl
; int 21h

call crlf

ret

main endp
;------------------------------------------------------------------------
crlf proc near
mov ah,02
mov dl,0dh
int 21h

mov ah,02
mov dl,0ah
int 21h

ret
crlf endp
;-------------------------------------------------------------------------
bin_dec proc near
push bx
push cx

and ax,00ffh
mov cx,0
mov bx,0
mov dl,10

rotate:
div dl

mov bl,ah
and ax,00ffh

push bx
inc cx

cmp ax,10
jae rotate

mov bx,ax
push bx
inc cx
continue:
pop bx
add bl,30h
mov dl,bl

mov ah,02h
int 21h
loop continue

pop cx
pop bx

ret
bin_dec endp
;-------------------------------------------------------------------------------
prognam ends
;*******************************************************************************
end main
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐