提供大小写转换两种功能,逻辑很简单。将输入的 字符串根据ascii之间的转换关系修改大小写,最后将字符串后添加$,输出字符串即可。
; multi-segment executable file template.
data segment
; add your data here!
question db "you can press 1(big->small)or2(small-<big) to choose option:$"
input db "please input a string:$"
string db 100 dup(0)
num dw 0
ends
stack segment
dw 128 dup(0)
ends
code segment
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; add your code here
lea dx,input
mov ah,9
int 21h
call CRLF
lea si,string
L1:
mov ah,1
int 21h
cmp al,0dh ;遇见回车结束输入
je L2
inc num
mov [si],al
inc si
jmp L1
L2:
mov [si],'$'
call CRLF
lea dx, question
mov ah, 9
int 21h
call CRLF ; output string at ds:dx
; add num,1
mov cx,num
lea si,string
mov ah,1
int 21h
cmp al,31h
je L6
cmp al,32h
je L7

本文介绍如何使用汇编语言实现英文字符串的大小写转换,通过ASCII码的对应关系,对输入字符串进行处理,并在末尾添加$符号,输出转换后的字符串。
最低0.47元/天 解锁文章
3237

被折叠的 条评论
为什么被折叠?



