home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / STAYRESP.ZIP / STAYXIT.410 < prev   
Encoding:
Text File  |  1986-06-12  |  2.6 KB  |  72 lines

  1. {****************************************************************************}
  2. {                       S T A Y X I T   .   I N C                            }
  3. {****************************************************************************}
  4. {-----------------------------------------------------------------------------}
  5. {  Stay_Xit Check Terminate Keys                                              }
  6. {                                                                             }
  7. {  Clean up the Program ,Free the Environment block, the program segment      }
  8. {  memory and return to Dos. Programs using this routine ,must be the         }
  9. {  last program in memory, else ,a hole will be left causing Dos              }
  10. {  to take off for Peoria.                                                    }
  11. {-----------------------------------------------------------------------------}
  12. Procedure Stay_Xit;
  13. {
  14.        This code reinstates those interrupts that will not be
  15.        restored by DOS. Interrupts 22,23,24 (hex) are restored
  16.        from the Current PSP during termination.
  17. }
  18.     Begin { Block }
  19.  
  20.        Rmwin;                          {Remove the Last Window}
  21.        Writeln ('Stay-Resident program Terminating') ;
  22.  
  23.       Inline($FA);                     {Disable interrupts}
  24.  
  25.           { Restore Disk Interrupt Service Routine  }
  26.  
  27.       Regs.Ax := $2500 + BIOSI13;
  28.       Regs.Ds := BIOS_INT13.CS;
  29.       Regs.Dx := BIOS_INT13.IP;
  30.       Intr ($21,Regs);
  31.  
  32.             { Restore Keyboard Interrupt Service Routine  }
  33.  
  34.       Regs.Ax := $2500 + BIOSI16;
  35.       Regs.Ds := BIOS_INT16.CS;
  36.       Regs.Dx := BIOS_INT16.IP;
  37.       Intr ($21,Regs);
  38.  
  39.             { Restore Timer Interrupt Service Routine  }
  40.  
  41.       Regs.Ax := $2500 + BIOSI8;
  42.       Regs.Ds := BIOS_INT8.CS;
  43.       Regs.Dx := BIOS_INT8.IP;
  44.       Intr ($21,Regs);
  45.  
  46.             { Restore DOS 21 Interrupt Service Routine  }
  47.  
  48.       Regs.Ax := $2500 + DOSI21;
  49.       Regs.Ds := DOS_INT21.CS;
  50.       Regs.Dx := DOS_INT21.IP;
  51.       Intr ($21,Regs);
  52.  
  53.             { Restore DOS 28 Interrupt Service Routine  }
  54.  
  55.       Regs.Ax := $2500 + DOSI28;
  56.       Regs.Ds := DOS_INT28.CS;
  57.       Regs.Dx := DOS_INT28.IP;
  58.       Intr ($21,Regs);
  59.  
  60.       Inline($FB);                        {Re-enable interrupts}
  61.  
  62.       Regs.Ax := $49 shl 8 + 0 ;   { Free Allocated Block function}
  63.       Regs.Es := MemW[Cseg:$2C] ;  { Free environment block       }
  64.       MsDos( Regs ) ;
  65.  
  66.       Regs.Ax := $49 shl 8 + 0 ;    { Free Allocated Block function}
  67.       Regs.Es := Cseg ;             { Free Program                 }
  68.       MsDos( Regs ) ;
  69.       Intr($20,Regs) ;                  { Return to Dos }
  70.  
  71.    End  { StayXit };
  72.