home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / WIH.ZIP / SIHREG.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-02-01  |  1.8 KB  |  43 lines

  1. Program Critical_Error_Handler;
  2. Type
  3.    RegisterSet=Record Case Integer Of
  4.                   1: (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: Integer);
  5.                   2: (AL,AH,BL,BH,CL,CH,DL,DH         : Byte);
  6.                 End;
  7. Var
  8.    Setup                : RegisterSet;
  9.    IntAX,IntBX,IntCX,IntDX,IntBP,IntSI,IntDI,IntDS,IntES,
  10.    IntFlags             : Integer;
  11.    Interupt_Registers   : RegisterSet Absolute IntAX;
  12. {Interupt_Registers must be Global so that they will be in the data segment
  13.  and can be accessed by any interupt handler or user procedure.
  14.  Local variables are in the stack segment which is not preserved.
  15.  Becuase they are global, however, it will be extra dangerous for one interupt
  16.  handler to call another.  To ensure that that will work,it may be necessary
  17.  to declare a second global register set.}
  18.  
  19. Procedure Interupt_Handler;
  20.   Const   Interupt_Number = $41;
  21.  
  22.   Procedure User_Procedure;
  23.     Const    Interupt_Counter  : Integer = 0;
  24.     Begin
  25.        Interupt_counter := Interupt_counter + 1;
  26.        WriteLn('Interupt ',Interupt_Number,' successfully handled ',
  27.               Interupt_Counter,' times in Turbo Pascal');
  28.        With Interupt_Registers Do Begin
  29.           WriteLn('Registers are:');
  30.           WriteLn('AX = ',AX,': BX = ',BX,': CX = ',CX);
  31.           WriteLn('DX = ',DX,': SI = ',SI,': DI = ',DI);
  32.           WriteLn('Enter Values for AX, BX, and DI registers...');
  33.           Read(AX,BX,DI); WriteLn; End;
  34.     End;
  35.  
  36.     (*$ISIH.INC*)
  37.  
  38. Begin
  39.   Interupt_Handler;              {initialize interupt}
  40.   Setup.DX := $400;              {reserved 16K memory for resident program}
  41.   Setup.AH := $31;               {DOS Function to terminate resident}
  42.   MsDos(Setup);
  43. End.