编写子程序,实现大小写转换
data segment
db "Beginner`s All-purpose Symbolic Instruction Code.",0
data ends
codesg segment
assume cs:codesg
start:
mov ax,data
mov ds,ax
mov si,0
call letterc
mov ax,4c00h
int 21h
;功能:将一个字符串的小写字母全转换为大写
;参数:ds:si表示字符串首地址,字符串以0结尾
letterc:
mov al,[si]
test al,al
jz lettercend
cmp al,'a'
jl notjump
cmp al,'z'
jg notjump
and al,0dfh
mov [si],al
notjump:
inc si
jmp letterc
lettercend:
ret
codesg ends
end start
注意每个字母占一字节,寄存器使用AL,不要写成AX