home *** CD-ROM | disk | FTP | other *** search
- {****************************************************************************}
- { S T A Y X I T . I N C }
- {****************************************************************************}
- {----------------------------------------------------------------------------}
- { Stay_Xit Check Terminate Keys }
- { }
- { Clean up the Program ,Free the Environment block, the program segment }
- { memory and return to Dos. Programs using this routine ,must be the }
- { last program in memory, else ,a hole will be left causing Dos }
- { to take off for Peoria. }
- {----------------------------------------------------------------------------}
- Procedure Stay_Xit;
- {
- This code reinstates those interrupts that will not be
- restored by DOS. Interrupts 22,23,24 (hex) are restored
- from the Current PSP during termination.
- }
- VAR
- PSPvector22: vector absolute Cseg:$0A;
- PSPvector23: vector absolute Cseg:$0E;
- PSPvector24: vector absolute Cseg:$12;
-
- DOSvector22: vector absolute 0:$88;
- DOSvector23: vector absolute 0:$8C;
- DOSvector24: vector absolute 0:$90;
-
- Begin { Block }
-
- Writeln ('Stay-Resident program Terminated') ;
-
- Inline($FA); {Disable interrupts}
-
- { Restore Disk Interrupt Service Routine }
-
- Regs.Ax := $2500 + BIOSI13;
- Regs.Ds := BIOS_INT13.CS;
- Regs.Dx := BIOS_INT13.IP;
- Intr ($21,Regs);
-
- { Restore Keyboard Interrupt Service Routine }
-
- Regs.Ax := $2500 + BIOSI16;
- Regs.Ds := BIOS_INT16.CS;
- Regs.Dx := BIOS_INT16.IP;
- Intr ($21,Regs);
-
- { Restore Timer Interrupt Service Routine }
-
- Regs.Ax := $2500 + BIOSI8;
- Regs.Ds := BIOS_INT8.CS;
- Regs.Dx := BIOS_INT8.IP;
- Intr ($21,Regs);
-
- { Restore DOS 21 Interrupt Service Routine }
-
- Regs.Ax := $2500 + DOSI21;
- Regs.Ds := DOS_INT21.CS;
- Regs.Dx := DOS_INT21.IP;
- Intr ($21,Regs);
-
- { Restore DOS 28 Interrupt Service Routine }
-
- Regs.Ax := $2500 + DOSI28;
- Regs.Ds := DOS_INT28.CS;
- Regs.Dx := DOS_INT28.IP;
- Intr ($21,Regs);
-
- { Move Interrupt Vectors 22,23,24 to our PSP from where DOS will restore }
-
- PSPvector22 := DOSvector22; { Terminate vector }
- PSPvector23 := DOSvector23; { Cntrl-C vector }
- PSPvector24 := DOSvector24; { Critical vector }
-
- Inline($FB); {Re-enable interrupts}
-
- Regs.Ax := $49 shl 8 + 0 ; { Free Allocated Block function}
- Regs.Es := MemW[Cseg:$2C] ; { Free environment block }
- MsDos( Regs ) ;
-
- Regs.Ax := $49 shl 8 + 0 ; { Free Allocated Block function}
- Regs.Es := Cseg ; { Free Program }
- MsDos( Regs ) ;
-
- End { StayXit };