发个帖子问个问题,王爽书上一条题目
assume cs:code,ds:data
data segment
db 'welcome to NASA',0
data ends
code segment
start:
mov ax,data
mov ds,ax
mov dh,8
mov dl,3
mov si,0
mov cl,02h
call show_str
mov ax,4c00h
int 21h
show_str:
push ax
push dx
push cx
push es
push di
push si
mov ax,0b800h
mov es,ax ;将显存段写入ES段,
sub ax,ax
mov al,160
sub dh,1
mul dh
sub dh,dh
add dl,dl ;这一句什么作用,求解释
add ax,dx
mov di,ax
mov al,cl
sub cx,cx
next:
mov cl,[si]
jcxz sret ;如果是字符,则CX不等于0,则继续执行下面代码,否则跳转到sret标记处
mov es:[di],cl
mov es:[di+1],al
inc si
add di,2
jmp short next
sret:
pop si
pop di
pop es
pop cx
pop dx
pop ax
ret
code ends
end start
assume cs:code,ds:data
data segment
db 'welcome to NASA',0
data ends
code segment
start:
mov ax,data
mov ds,ax
mov dh,8
mov dl,3
mov si,0
mov cl,02h
call show_str
mov ax,4c00h
int 21h
show_str:
push ax
push dx
push cx
push es
push di
push si
mov ax,0b800h
mov es,ax ;将显存段写入ES段,
sub ax,ax
mov al,160
sub dh,1
mul dh
;此时ax=160*7
sub dh,dh
add dl,dl
;目测此句前面该有个sub dl,1因为书上要求放在第8行第3列
add ax,dx;字符串在彩色字符显示模式视频缓冲区(80列*25行)的首地址是ax=160*7+2*3(第8行第3列)
mov di,ax
mov al,cl
sub cx,cx
next:
mov cl,[si]
jcxz sret ;如果是字符,则CX不等于0,则继续执行下面代码,否则跳转到sret标记处
mov es:[di],cl
mov es:[di+1],al
inc si
add di,2
jmp short next
sret:
pop si
pop di
pop es
pop cx
pop dx
pop ax
ret
code ends
end start