assume cs:codesg
datasg segment
db 'Beginnner`s All-purpose Symbolic Instruction Code.',0
datasg ends
codesg segment
begin: mov ax,datasg
mov ds,ax
mov si,0
;转换前回显字符串
call showstr
;执行转换函数
call letterc
;换行
mov dl, 10
MOV AH,6
INT 21H
mov dl, 13
MOV AH,6
INT 21H
;转换后回显字符串
call showstr
mov ax,4c00h
int 21h
;把小写字母转换为大小字母的函数
letterc:
;保存现场
push ax
push cx
push si
start: ;判断读取到的字符是否为0
;若为0就跳转到返回功能块
mov ch,0
mov cl,[si]
jcxz endfunc
;若不是0就继续
;判断读取到的字符是否为小写字符
mov al,61h
cmp cl,al
jb continue ;如果ASCII码小于97(a)跳过转换步骤继续遍历字符串
mov al,7ah
cmp cl,al
ja continue ;如果ASCII码大于122(z)跳过转换步骤继续遍历字符串
;如果经历这么多困难还执行到这一步,那么呵呵,你就肯定要变大咯!!
and cl,11011111b
mov [si],cl
continue:
inc si
jmp short start
endfunc:
;函数结束恢复现场
pop si
pop cx
pop ax
ret
;回显ds:[si]中的字符串,以0作为结束标志
showstr:
;保存现场
push ax
push cx
push si
;判断读取到的字符是否为0
;若为0就跳转到返回功能块
strbegin: mov ch,0
mov cl,[si]
jcxz strend
mov dl, [si]
MOV AH,02
INT 21H
INC si
loop strbegin
strend:
;恢复现场
pop si
pop cx
pop ax
ret
codesg ends
end begin