home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / MADTRB20.ZIP / STAYXIT.320 < prev    next >
Encoding:
Text File  |  1985-09-05  |  2.3 KB  |  43 lines

  1. {****************************************************************************}
  2. {                       S T A Y X I T   .   I N C                            }
  3. {                                                                            }
  4. {     Separate this file into "StayXIT.320" to provide a "Go-non-Resident"   }
  5. {                   routine or the Stay-Resident Demo.                       }
  6. {                                                                            }
  7. {****************************************************************************}
  8. Procedure Stay_Xit;
  9. {-----------------------------------------------------------------------------}
  10. {  Stay_Xit Check Terminate Keys                                              }
  11. {                                                                             }
  12. {  Clean up the Program ,Free the Environment block, the program segment      }
  13. {  memory and return to Dos. Programs using this routine ,must be the         }
  14. {  last program in memory, else ,a hole will be left causing Dos              }
  15. {  to go GooGoo .                                                             }
  16. {-----------------------------------------------------------------------------}
  17.  
  18.    Begin { Block }
  19.             Rmwin;
  20.             Writeln ('Stay-Resident program Terminating') ;
  21.             SaveRegs.Ax := $35 shl 8 + User_Int;
  22.             MsDos(SaveRegs);           {get the original Int 16 Addr   }
  23.  
  24.             SaveRegs.Ax := $25 shl 8 + Kybrd_Int;
  25.             SaveRegs.Ds := SaveRegs.Es;
  26.             SaveRegs.Dx := SaveRegs.Bx; { Reset the Keyboard interrupt addr }
  27.             MsDos(SaveRegs);            { to its original value             }
  28.  
  29.             MemW[$00:User_Int * 4] := 0 ;    { Clear User Interrupt vector  }
  30.             MemW[$00:User_Int * 4 + 2] :=0;
  31.  
  32.             Saveregs.Ax := $49 shl 8 + 0 ;   { Free Allocated Block function}
  33.             Saveregs.Es := MemW[Cseg:$2C] ;  { Free environment block       }
  34.             MsDos( Saveregs ) ;
  35.  
  36.             Saveregs.Ax := $49 shl 8 + 0 ;    { Free Allocated Block function}
  37.             Saveregs.Es := Cseg ;             { Free Program                 }
  38.             MsDos( Saveregs ) ;
  39.  
  40.             Intr($20,Regs) ;                  { Return to Dos }
  41.  
  42.    End  { StayXit };
  43.