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

  1. Program Sample_Interupt_Handler;
  2. (*$INEWSCRN.INC *)
  3. Type
  4.    RegisterSet=Record Case Integer Of
  5.                   1: (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: Integer);
  6.                   2: (AL,AH,BL,BH,CL,CH,DL,DH         : Byte);
  7.                 End;
  8. Var
  9.    Setup                : RegisterSet;
  10.    IntAX,IntBX,IntCX,IntDX,IntBP,IntSI,IntDI,IntDS,IntES,
  11.    IntFlags             : Integer;
  12.    Interupt_Registers   : RegisterSet Absolute IntAX;
  13. {Interupt_Registers must be Global so that they will be in the data segment
  14.  and can be accessed by any interupt handler or user procedure.
  15.  Local variables are in the stack segment which is not preserved.
  16.  Becuase they are global, however, it will be extra dangerous for one interupt
  17.  handler to call another.  To ensure that that will work,it may be necessary
  18.  to declare a second global register set.}
  19. (*----------------------------------------------------------------------*)
  20. Procedure Interupt_Handler;
  21. Const Interupt_Number = $41;
  22.  
  23.   Procedure User_Procedure;
  24.     Var
  25.        C                : Char;
  26.     Const
  27.        Interupt_Counter : Integer = 0;
  28.     Begin
  29.        Interupt_counter := Interupt_counter + 1;
  30.        Save_Screen(Saved_Screen);
  31.        Draw_Menu_Frame(16,6,64,16,15,7,
  32.                        ' Sample Interupt Handler ');
  33.        WriteLn(bell);
  34.        WriteLn('Interupt $41 successfully handled ',Interupt_Counter,
  35.                ' times.');
  36.        With Interupt_Registers Do Begin
  37.           WriteLn('Registers are:');
  38.           WriteLn('AX = ',AX,': BX = ',BX,': CX = ',CX);
  39.           WriteLn('DX = ',DX,': SI = ',SI,': DI = ',DI);
  40.           WriteLn('Enter Values for AX, BX, and DI registers...');
  41.           Read(AX,BX,DI); WriteLn; End;
  42.        WriteLn('    Press any key to continue');
  43.        Read(Kbd,c);
  44.        Restore_Screen(Saved_Screen);
  45.     End;
  46.  
  47. (*$ISIH.Inc *)
  48.  
  49. (*----------------------------------------------------------------------*)
  50. Begin {Main Program}
  51.      Get_Screen_Address;
  52.      Interupt_Handler;
  53.      Setup.DX := $800;
  54.      Setup.Ah := $31;
  55.      MsDos(Setup);
  56. End.
  57.