1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| assume cs:code,ds:data,ss:stack
data segment db 'divide error',0 ;会被覆盖掉 CPU需要立刻处理的程序 ;0:200 0:3FF data ends
stack segment stack db 128 dup (0) stack ends
code segment
start: mov ax,stack mov ss,ax mov sp,128
call cpy_new_int0 call set_new_int0 mov ax,0 mov dx,1 mov bx,1 div bx
mov ax,4c00h int 21h
;=================================== set_new_int0: mov bx,0 mov es,bx
mov word ptr es:[0*4],7e00h mov word ptr es:[0*4+2],0
ret
;=================================== new_int0: jmp newint0
string: db 'divide error',0
newint0: mov bx,0800h mov es,bx
mov bx,0 mov ds,bx
mov di,160*10 + 30*2 mov si,7e03h
mov dl,ds:[si] cmp dl,0 je showStringRet mov es:[di],dl add di,2 inc si jmp showString
mov ax,4c00h int 21h
new_int0_end: nop
;=================================== cpy_new_int0: mov bx,cs mov ds,bx mov si,offset new_int0
mov bx,0 mov es,bx mov di,7e00h
mov cx,offset new_int0_end - new_int0 cld rep movsb
ret
code ends
end start
|