【过程】
- 将中断处理程序放入0000:0200处
- 将中断处理程序入口地址登记在中断向量表的对应表项中(除法溢出对应的中断类型码为0,它的中断程序的入口地址应该是从 0*4 地址单元开始存放,段地址在 0*4+2 字单元中)
【源程序】
assume cs:code
code segment
start:
mov ax,cs
mov ds,ax
mov si,offset do0
mov ax,0
mov es,ax ;es = 0000
mov di,200h ;将中断程序do0放在0000:0200后
mov cx,offset do0end - offset do0 ;传输长度
cld
rep movsb ;rep的作用是根据cx的值,重复执行后面的串传送指令,rep movsb可以循环实现cx个字符的传送
;df = 0;es:[di] = ds:[si],++si;++di
;设置中断向量表
mov ax,0
mov es,ax
mov word ptr es:[0*4],200h ;将do0的入口地址登记在中断向量表的对应表项中,低位IP,高位cs
mov word ptr es:[0*4+2],0
mov ax,1000h ;测试除法溢出数据
mov bh,1
div bh
mov ax,4100h
int 21h
do0:
jmp do0start
db 'divide error!'
do0start:
mov ax,cs
mov ds,ax
mov si,202h ;前两个单元存放的do0的jmp指令,