home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TASMSWAN.ZIP / DIV286.ASM < prev    next >
Assembly Source File  |  1989-07-17  |  2KB  |  86 lines

  1. %TITLE  "80286/386 divide-fault ISR installer"
  2.  
  3.     IDEAL
  4.     DOSSEG
  5.     MODEL    tiny
  6.  
  7. ;----- Equates
  8. cr        EQU    13
  9. lf        EQU    10
  10.  
  11.     DATASEG
  12.  
  13. welcome        db    cr,lf,'80286/386 Divide-Fault handler installed'
  14.         db    cr,lf,'Address = ', 0
  15. string        db    40 DUP (?)
  16.  
  17.     CODESEG
  18.  
  19.     ORG    100h
  20.  
  21.     EXTRN    StrWrite:proc, BinToAscHex:proc, NewLine:proc
  22.  
  23.  
  24. Start:
  25.     jmp    Begin
  26.  
  27. %NEWPAGE
  28. ;------------------------------------------------------------------------
  29. ; DivFault - divide-fault handler ISR
  30. ;------------------------------------------------------------------------
  31. ;    Input:  none (called internally upon a DIV or IDIV fault)
  32. ;    Output:  ax = 0 (al = 8-bit quotient, ax = 16-bit quotient)
  33. ;           NOTE: program continues normally with the instruction
  34. ;            following the DIV or IDIV that caused the fault.
  35. ;       Registers:  ax changed
  36. ;------------------------------------------------------------------------
  37. PROC    DivFault
  38.     sti
  39.     push    bp
  40.     mov    bp,sp
  41.     push    si
  42.     push    ds
  43.     lds    si,[bp + 2]
  44.     lodsw
  45.     and    ah,0C0h
  46.     cmp    ah,0C0h
  47.     je    @@10
  48.     add    [word bp + 2], 2
  49. @@10:    add    [word bp + 2], 2
  50.     xor    ax,ax
  51.     pop    ds
  52.     pop    si
  53.     pop    bp
  54.     iret
  55. ENDP    DivFault
  56.  
  57. Begin:
  58.     mov    ax,2500h
  59.     mov    dx, offset DivFault
  60.     int    21h
  61.     mov    di, offset welcome
  62.     call    StrWrite
  63.     mov    ax,cs
  64.     call    ShowAX
  65.     mov    dl, ':'
  66.     mov    ah,2
  67.     int    21h
  68.     mov    ax, offset DivFault
  69.     call    ShowAX
  70.     call    NewLine
  71. Exit:
  72.     mov    dx, offset Begin
  73.     int    27h
  74.  
  75.  
  76.  
  77. PROC    ShowAX
  78.     mov    cx,4
  79.     mov    di, offset string
  80.     call    BinToAscHex
  81.     call    StrWrite
  82.     ret
  83. ENDP    ShowAX
  84.  
  85.     END    Start
  86.