assume cs:code
data segment
db 'welcome to masm!',0
data ends
code segment
start: mov dh,11;显示的内容所在行
mov dl,39;显示的内容所在列
mov cl,24;显示的内容的格式
mov ax,data
mov ds,ax
mov si,0
call show_str;调用现实内容的子程序
mov ax,4c00h
int 21h
show_str: push dx;把dx,si,cx存入栈中
push si
push cx
mov di,0
mov ah,0
mov al,0ah;把行之间的长度赋予al
mul dh;计算行的偏移位移
add ax,0b800h;计算行的实际段地址
mov es,ax
mov ah,0
mov al,2h;把列之间的长度赋予al
mul dl;计算列的实际偏移地址
mov di,ax
mov ah,cl;把cl的值赋予ah,cl的值表示字符的格式
show: mov ch,0
mov cl,[si];判断要显示的内容是否结束
jcxz ok;结束则不再执行下列代码
mov al,[si]
mov es:[di],ax;在显存缓冲区写入要显示的字符
inc si
add di,2h
jmp short show
ok: pop cx
pop si
pop dx
ret
code ends
end start |