For a divide by zero trap. I know the system trap for this goes like:


.MODEL SMALL
.STACK 100H
.DATA
n1    DB    0
.CODE
main  PROC
    .STARTUP
      mov  AL,10
div  n1            ; look up div instruction                     
    .EXIT
main  ENDP
END    main


How would I be able to modify the ISR to change the standard error message "Divide overflow" to something else? Thanks.
Posted on 2009-11-14 18:50:33 by dre
How do you want to handle #DE fault? It's not for division by zero only: will be generated also if division overflows (result does not fit into destination).

mov dx, cx
div cx ; will overflow


You can use int 21h function 25h to set int 00h interrupt vector to point to your function, which should use interrupt calling convention: iret instead of ret, interrupts are disabled upon entry, topmost parameter is far (16:16) pointer to fault address (i.e. it points to div instruction), next parameter is flags.

There are some guidelines for writing exception/interrupt handlers, google them.
Posted on 2009-11-15 04:41:20 by baldr