.model small
.stack
.data
strbuf db 41
db ?
string db 41 dup(?)
count db 0
mesg1 db 'the checked string is: ','$'
mesg2 db 'the characters number of the string is:','$'
enter db 0dh,0ah,'$'
.code
.startup
start:
mov dx,offset strbuf
mov ah,0ah
int 21h
mov al,[strbuf+1]
cmp al,28h
ja check
xor ah,ah
mov bx,offset string
add bx,ax
mov dl,24h
mov [bx],dl
mov cx,ax
mov bx,offset string
xor al,al
check:
mov dl,[bx]
cmp dl,'Z'
jb continue
cmp dl,5ah
ja next1
inc count
add dl,20h
mov [bx],dl
jmp continue
next1:
cmp dl,61h
jb continue
cmp dl,7ah
ja continue
inc count
sub dl,20h
mov [bx],dl
jmp continue
continue:
inc bx
loop check
displaystr:
mov dx,offset mesg1
mov ah,09h
int 21h
mov dx,offset string
mov ah,09h
int 21h
mov dx,offset enter
mov ah,09h
int 21h
mov dx,offset mesg2
mov ah,09h
int 21h
mov dl,count
add dl,30h
mov ah,02h
int 21h
mov dx,offset enter
mov ah,09h
int 21h
mov ah,4ch
int 21h
.exit 0
end
这里可以用XOR DL,20H语句
可以将小写字母装换为大写字母,大写字母转化为小写字母