当前位置: 代码迷 >> 汇编语言 >> 汇编中出现的一个有关问题
  详细解决方案

汇编中出现的一个有关问题

热度:119   发布时间:2016-05-02 04:31:46.0
汇编中出现的一个问题

assume cs:code,ss:stack

stack segment
db 64 dup (0)
stack ends

code segment
start: mov ax,stack
mov ss,ax
mov sp,32
mov ax,0
mov dx,0fh
mov ax,4240h
mov cx,1
call divdw

mov ax,4c00h
int 21h

divdw:
push bx
push si
push di

push ax
mov ax,dx
div cl
push dx
;mul 65536
mov bx,ax
mov dx,65535
mul dx
add ax,bx
adc dx,0
mov si,dx
mov di,ax
pop ax
mov bx,ax
mov dx,65535
mul dx
add ax,bx
adc dx,0
pop bx
add ax,bx
adc dx,0
div cx
mov cx,dx    //出问题
add di,ax
adc si,0
mov dx,si
mov ax,di

pop di
pop si
pop bx

retf
code ends

end start


这段代码在编译连接的时候没出问题,但是运行的时候出问题了,debug里面发现mov cx,dx这条指令变成了??? [bx+si],这是什么问题呢..
------解决思路----------------------
用的 DOSBox ?仔细看下这是的 CS:IP,已经不是你程序的范围了吧,是前面的 div cx 指令溢出了,触发了 div0 异常。这个 DOSBox 的 div0 异常处理好像也是不对的,看了下 xp/sp3 的 dos 的不是这样的。
  相关解决方案