输入一个字符串,计算该字符串中字母的个数,并将大写字母转化为小写字母,小写字母转化为大写字母

这是一个小型的汇编程序,用于读取用户输入的字符串,计算其中字母的数量,并将所有大写字母转为小写字母,小写字母转为大写字母。程序最后会显示转换后的字符串及字母总数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

.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语句
可以将小写字母装换为大写字母,大写字母转化为小写字母

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值