home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TP_ADV.ZIP / LIST0705.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-11-17  |  1.5 KB  |  49 lines

  1. Unit BreakOut;
  2. { This Unit will intercept hardware interrupt $9 and check for a Ctrl-Break.  }
  3. { If the interrupt does not contain a Ctrl-Break the preceding Int9 is called.}
  4. { If Ctrl-Break was pressed we call Turbo's int23 handler to stop execution   }
  5. { of the program, while still executing the ExitProcs.                        }
  6.  
  7. INTERFACE
  8.  
  9. Uses DOS,CRT;
  10.  
  11. IMPLEMENTATION
  12.  
  13. Var
  14.   Int23,
  15.   OldExit,
  16.   OldKBD : pointer;
  17.  
  18. Procedure JmpOldISR ( OldISR: pointer );
  19.   Inline ( $5B/$58/$87/$5E/$0E/$87/$46/$10/$89/
  20.            $EC/$5D/$07/$1F/$5F/$5E/$5A/$59/$CB );
  21.  
  22. {$F+}
  23. Procedure Key_ISR; Interrupt;
  24. Begin
  25.   If CheckBreak AND ( ( Mem [0000:$0417] AND 4 ) = 4 ) AND 
  26.                     ( Port[$60] = 70 ) Then
  27.     Begin
  28.       Inline ( $E4/$61/$8A/$E0/$0C/$80/$E6/$61/   { Clean up as the    }
  29.                $86/$E0/$E6/$61/$B0/$20/$E6/$20 ); { Bios would         }
  30.       JmpOldISR( Int23 );   {Jump to current Int23 handler (turbo's) }
  31.     End;
  32.   JmpOldISR( OldKBD );       {Jump to Old Keyboard handler }
  33. End;
  34.  
  35. Procedure Exitit;
  36. Begin
  37.   ExitProc := OldExit;        { Restore Old ExitProc pointer }
  38.   SetIntVec ( 9, OldKBD );    { Restore Old Int9 Handler     }
  39. End;
  40. {$F-}
  41.  
  42. Begin
  43.   OldExit := ExitProc;        { Save old ExitProc pointer }
  44.   ExitProc := @Exitit;        { Set new ExitProc pointer  }
  45.   GetIntVec ( $23, Int23 );   { Get Turbo's Int23 Vector  }
  46.   GetIntVec ( 9, OldKBD );    { Get Current Int9  Vector  }
  47.   SetIntVec ( 9, @Key_ISR );  { Set Int9 to our routine   }
  48. End.
  49.