?? 2.3分類統計字符個數.asm
字號:
;分類統計字符個數
DATAS SEGMENT
letter db ?
digit db ?
other db ?
mess1 db 'Please input the sentence which you want to count:','$'
letter0 db 'The sum of letters is ','$'
digit0 db 'The sum of digits is ','$'
other0 db 'The sum of other letters is ','$'
h db 'H','$'
DATAS ENDS
;***********************************************
CODES SEGMENT
;----------------------------------------------
main proc far
ASSUME CS:CODES,DS:DATAS
START:
push ds
xor ax,ax
push ax
;
MOV AX,DATAS
MOV DS,AX
;
mov cl,0;letter
mov dl,0;digit
mov dh,0;other
;
lea dx,mess1
mov ah,09h
int 21h
get_key:
mov ah,1
int 21h
cmp al,0dh
je disp
jne count
;
disp:
call crlf
push dx
lea dx,letter0
mov ah,09h
int 21h
pop dx
;
mov letter,cl
mov bh,0
mov bl,cl
call binihex
;
push dx
lea dx,h
mov ah,09h
int 21h
pop dx
;
call crlf
push dx
lea dx,digit0
mov ah,09h
int 21h
pop dx
;
sub dl,3
mov digit,dl
mov bh,0
mov bl,dl
call binihex
;
push dx
lea dx,h
mov ah,09h
int 21h
pop dx
;
call crlf
push dx
lea dx,other0
mov ah,09h
int 21h
pop dx
;
mov other,dh
mov bh,0
mov bl,dh
call binihex
;
push dx
lea dx,h
mov ah,09h
int 21h
pop dx
;
jmp exit
;
count:
cmp al,'z'
jbe a
jmp short others
a:
cmp al,'a'
jb b
jmp short letters
;
b:
cmp al,'9'
jbe d
jmp short others
;
d:
cmp al,'0'
jb others
jmp short digits
exit:
ret
letters:
inc cl
jmp get_key
digits:
inc dl
jmp get_key
others:
inc dh
jmp get_key
;
main endp
;-------------------------------------------------
binihex proc near
;
push cx
push dx
;
mov ch,4
rotate:
mov cl,4
rol bx,cl
mov al,bl
and al,0fh
add al,30h
cmp al,3ah
jl printit
add al,7h
printit:
mov dl,al
mov ah,2
int 21h
dec ch
jnz rotate
;
pop dx
pop cx
;
ret
;
binihex endp
;------------------------------------------------
crlf proc near
push dx
;
mov ah,02h
mov dl,0dh
int 21h
mov ah,02h
mov dl,0ah
int 21h
;
pop dx
ret
crlf endp
;---------------------------------------------------
CODES ENDS
END START
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -