data segment
str1 db 0dh,0ah,'input error! $'
str2 db 0dh,0ah,'input your char:$'
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
lea dx,str2 ;显示输入信息
mov ah,9
int 21h
mov ah,01h ;调用21中断01功能。。输入字符
int 21h
cmp al,61h
jb exit
cmp al,7ah
ja exit
sub al,32
mov dl,al;显示转换后字母
mov ah,02h
int 21h
mov ah,4ch;返回dos
int 21h
exit:
lea dx,str1 ;显示错误信息
mov ah,9
int 21h
mov ah,4ch;返回dos
int 21h
code ends
end start
data segment
chars db 200 dup(?) ;开辟200字节的缓冲区
data ends
;---------------------------------
code segment
assume cs:code,ds:data
start :
push ds
mov ax,0
push ax
mov ax,data
mov ds,ax
lea bx ,chars
mov si,0
mov ch,0
;----------------------输入字符子程序
scanf:
mov ah,1
int 21h
cmp al,0dh
jz crt
cmp al,61h
jnb L1 ;al>='a'
mov [bx],al
inc bx
inc ch
jmp scanf
;--------------------------
;-----------------------输出字符
crt:
mov dl,chars[si]
mov ah,2
int 21h
inc si
dec ch
jz exit
jmp crt
;----------------------
exit:
mov ah,4ch
int 21h
;----------------------
L1:
cmp al,7ah ;al<='z'
jbe L2
mov [bx],al
inc bx
inc ch
jmp scanf
;---------------------
L2:
sub al,20h
mov [bx],al
inc bx
inc ch
jmp scanf
;---------------------
code ends
end start
或者
data segment
a db 'abcd$'
b db 'abcd$'
data ends
stack segment stack
db 200 dup(?)
stack ends
code segment
assume cs:code,ds:data,ss:stack
a1 proc far
start:mov ax,data
mov ds,ax
mov cx,10
call upper
mov dx,offset b
mov ah,9h
int 21h
mov ah,4ch
int 21h
a1 endp
upper proc near
mov si,0
mov cx,4
l1: mov dl,a[si]
mov al,20h
sub dl,al
mov b[si],dl
inc si
loop l1
ret
upper endp
code ends
end start