下面是第二题的:(谢谢langzi1190)
data segment
count_char db 80,0,80 dup(?)
letter db ?
number db ?
other db ?
message1 db 'input a string!','$'
message2 db 'the string contains numbers: ','$'
message3 db 'the string contains letters: ','$'
message4 db 'the string contains other ascii :','$'
flag db 0
data ends
code segment
assume cs:code,ds:datastart: mov ax,data
mov ds,ax
lea dx,message1
mov ah,09h
int 21h
lea dx,count_char
mov ah,0ah
int 21h
mov dl,0dh
mov ah,02h
int 21h
mov dl,0ah
mov ah,02h
int 21h
mov bh,0h
mov bl,0h
mov al,0h
mov si,02h
mov cl,count_char[1]
mov ch,0hloop1:
cmp count_char[si],7bh;'{'
jl jmpa1
jmp loopa
jmpa1:
cmp count_char[si],'a'
jl jmpz1
jmp loopb
jmpz1:
cmp count_char[si],5bh;'['
jl jmpa2
jmp loopa
jmpa2:
cmp count_char[si],'A'
jl jmp9
jmp loopb
jmp9:
cmp count_char[si],3ah;':'
jl jmp1
jmp loopa
jmp1:
cmp count_char[si],2fh;'/'
jg loopc
jmp loopa
loopa:
inc bh
inc si
loop loop1
jmp finish
loopc: inc al
inc si
loop loop1
jmp finish
loopb:
inc bl
inc si
loop loop1
finish:
mov dl,count_char[1]
sub dl,bh
sub dl,bl
mov letter,bl
mov other,bh
mov number,dl
lea dx,message2
mov ah,09h
int 21h
mov bl,number
jmp output
back:
cmp flag,02h
jz back1
lea dx,message3
mov ah,09h
int 21h
mov bl,letter
jmp output
back1: lea dx,message4
mov ah,09h
int 21h
mov bl,other
int 21h
mov bl,other
output:
mov bh,0h
mov ch,2rotate1:
mov cl,4
rol bl,cl
mov al,bl
and al,0fh
add al,30h
cmp al,3ah
jl printit1
add al,7h
printit1:
mov dl,al
mov ah,02h
int 21h
dec ch
jnz rotate1
mov dl,0dh
; enter a new line
mov ah,02h
int 21h
mov dl,0ah
mov ah,02h
int 21h
inc flag
cmp flag,03h
jl back
mov ah,4ch
int 21h
code ends
end start