assume cs:code
data segment
db 'Welcome to masm!',0
data ends
stack segment
dw 16 dup(0)
stack ends
code segment
start: mov dh,8 ;行号
mov dl,3 ;列号
mov cl,11001001b ;属性
mov ax,data
mov ds,ax
mov ax,stack
mov ss,ax
mov sp,20h
mov si,0
call show_str
mov dh,9
call show_str
mov ax,4c00h
int 21h
;指定位置显示字符串
;dh 行号
;dl 列号
;cl 属性
;ds:[si] 字符串地址
show_str: push ax
push bx
push dx
push si
push di
push es
push cx
mov ax,0b800h
mov es,ax
;计算显示起始位dh*160+dl*2
mov al,160
mul dh
mov bx,ax
mov al,2
mul dl
add bx,ax
mov al,cl
mov di,0
s_co:
mov cl,[si]
mov ch,0
jcxz ok
mov ch,al
mov word ptr es:[bx+di],cx
inc si
add di,2
jmp short s_co
ok: pop cx
pop es
pop di
pop si
pop dx
pop bx
pop ax
ret
code ends
end start