程序执行错误,B800段内存无法写入
STACKS SEGMENTdw 10 dup(0)
STACKS ENDS
data segment
db 10 dup(0)
data ends
code segment
assume cs:code,ss:stacks,ds:data
start:
mov ax,stacks
mov ss,ax
mov sp,20
mov ax,12666
mov bx,data
mov ds,bx
mov si,0
call dtoc
mov dh,8
mov dl,3
mov cl,2
call show_str
mov ax, 4c00h
int 21h
dtoc:
add si,2
mov bx,10
mov dx,0
s: div bx
mov cx,ax
add dx,30h
mov ds:[si],dx
mov dx,0
jcxz ok
add si,2
jmp short s
ok: ret
show_str:
mov al,0a0h
mul dh
mov bx,ax
mov al,2
mul dl
add bx,ax
mov ax,0b800h
mov es,ax
s1:
mov ch,0
push cx
mov cx,si
jcxz ok1
pop cx
mov es:[bx+1],cl ;调试到这一段发现,cl的2无法写入到es:[507]中,指令运行完es:[507]中是F0
mov al,ds:[si]
mov es:[bx],al ;es:[506]中是20,而不是31
add bx,2
sub si,2
jmp short s1
ok1:ret
code ends
end start