?? ben23.asm
字號:
data segment para 'data'
string label byte
max db 80
num db ?
str db 80 dup(?)
letters db 00h
digits db 00h
others db 00h
mess1 db 'please input your string:','$'
mess2 db 'the letters are:','$'
mess3 db 'the digits are:','$'
mess4 db 'other chars are:','$'
data ends
code segment para 'code'
main proc far
assume cs:code,ds:data,es:data
start: push ds ;start up for the program
sub ax,ax
push ax
mov ax,data
mov ds,ax
mov es,ax
lea dx,mess1
mov ah,09h
int 21h
lea dx,string
mov ah,0ah
int 21h
cmp num,0
jne follow
jmp exit
follow: mov letters,00h ;clear up the register
mov digits,00h
mov others,00h
call crlf
sub cx,cx
mov cl,num
lea di,str
lable: mov ax,[di] ;decide the charater you input
cmp al,30h
jb other ;if x<30,other+1
cmp al,3ah
jb digit ;if 30=<x<3a,digit+1
cmp al,41h
jb other ;if 3a=<x<41,other+1
cmp al,5bh
jb letter ;if 41=<x<5b,letter+1
cmp al,61h
jb other ;if 5b=<x<61,other+1
cmp al,7bh
jb letter ;if 61=<x<7b,letter+1
jmp other ;if then other+1
lo: loop lable
jmp output
digit: add digits,1 ;digit part
inc di
jmp lo
letter: add letters,1 ;letter part
inc di
jmp lo
other: add others,1 ;other part
inc di
jmp lo
output: lea dx,mess2
mov ah,09h
int 21h
mov bl,letters
call printn
call crlf
lea dx,mess3
mov ah,09h
int 21h
mov bl,digits
call printn
call crlf
lea dx,mess4
mov ah,09h
int 21h
mov bl,others
call printn
call crlf
jmp start
printn proc near
mov ch,2
rotate: mov cl,4 ;change the number from binary to hex
rol bl,cl
mov al,bl
and al,0fh
add al,30h
cmp al,3ah
jl printit
add al,7h
printit: ;output the hex by one bit
mov dl,al
mov ah,02h
int 21h
dec ch
jnz rotate
ret
printn endp
crlf proc near ;enter and change row
mov dl,13
mov ah,02h
int 21h
mov dl,10
mov ah,02h
int 21h
ret
crlf endp
exit:
mov ax,4c00h
int 21h
main endp
code ends
end start
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -