相对短一些,好理解assume cs:code
data segment
db 'welcome to masm!',0
data ends
code segment
start:
mov dh,8
mov dl,3
mov cl,2
mov ax,data
mov ds,ax
mov si,0
mov di,0
call show_str
mov ax,4c00h
show_str:
push si
push di
push cx
push dx
push ax
next1:
mov al,0a0h ;一行有160个字节
mul dh
mov di,al ;把偏移给di
mov al,2 ;dl取值范围(0~79),所以,一行是160个字节
mul dl
add di,al
sub di,1 ;因为是0~159一共160字节,所以自减1,自减指令忘记了
s:
mov al,ds:[si]
mov ch,al ;把ds的偏移内容给ch
mov es:[di],al
mov es:[di+1],cl ;把颜色给奇地址
jcxz ok
inc si
add di,2 ;因为偶地址放数据,奇地址放属性
ok:
pop ax
pop dx
pop cx
pop di
pop si
ret
|