当前位置: 代码迷 >> 汇编语言 >> 王爽老师的书中编的中止程序为什么还没有执行div ,就提前显示“overflow”
  详细解决方案

王爽老师的书中编的中止程序为什么还没有执行div ,就提前显示“overflow”

热度:5685   发布时间:2013-02-26 00:00:00.0
王爽老师的书中编的中断程序为什么还没有执行div ,就提前显示“overflow”?
程序如下-
---------
assume cs:code
code segment
start:mov ax,cs
  mov ds,ax
  mov si,offset do0
  mov ax,0
  mov es,ax
  mov di,200h
  mov cx,offset do0end-offset do0
  cld
  rep movsb
  mov ax,0
  mov es,ax
  mov word ptr es:[0*4],200h
  mov word ptr es:[0*4+2],0
  mov ax,1000h
  mov bh,1
  div bh
  mov ax,4c00h
  int 21h
do0:jmp short do0start
  db "divide error!"
do0start:mov ax,cs
  mov ds,ax
  mov si,202h
  mov ax,0b800h
  mov es,ax
  mov di,12*0a0h+2*32
  mov cx,13d
  s:mov al,[si]
  mov es:[di],al
  inc si
  add di,2
  loop s
  mov ax,4c00h
  int 21h
do0end:nop
code ends
end start
-------------

AX=0000 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=0065 DI=0231
DS=0C1C ES=0000 SS=0C1C CS=0C1C IP=0021 NV UP EI PL NZ NA PO NC
0C1C:0021 26 ES:
0C1C:0022 C70602000000 MOV WORD PTR [0002],0000 ES:0002=00A7
-t

AX=0000 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=0065 DI=0231
DS=0C1C ES=0000 SS=0C1C CS=0C1C IP=0028 NV UP EI PL NZ NA PO NC
0C1C:0028 B80010 MOV divide error!
-t

AX=1000 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=0065 DI=0231
DS=0C1C ES=0000 SS=0C1C CS=0C1C IP=002B NV UP EI PL NZ NA PO NC
0C1C:002B B701 MOV BH,01
-t

AX=1000 BX=0100 CX=0000 DX=0000 SP=0000 BP=0000 SI=0065 DI=0231
DS=0C1C ES=0000 SS=0C1C CS=0C1C IP=002D NV UP EI PL NZ NA PO NC
0C1C:002D F6F7 DIV BH
-t

Program terminated normally
-

------解决方案--------------------------------------------------------
dx先清0
  相关解决方案