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