assume cs:code
data segment
db 'Welcome to masm!',0
data ends
code segment
start:
mov dh,8
mov dl,3
mov cl,00000010b
mov ax,data
mov ds,ax
mov si,0
call show_str
mov ax,4c00h
int 21h
;名称:show_str
;功能:在指定位置,用指定颜色,显示一个用0结束的字符串
;参数:(dh)=行号(取值范围0~24),(dl)=列号(取值范围0~79),(cl)=颜色,ds:si指向字符串首地址
;结果:没有返回值
show_str:
push ax
push cx
push dx
push es
push si
push di
mov ax,0b800h
mov es,ax
mov al,0a0h
mul dh
mov di,ax
mov dh,0
add dl,dl
add di,dx
mov dl,cl
disy:
mov cl,[si]
mov ch,0h
jcxz ok
mov ax,[si]
mov es:[di],ax
mov es:1[di],dl
inc si
add di,2
loop disy
ok:
pop di
pop si
pop es
pop dx
pop cx
pop ax
ret
code ends
end start |