home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l440 / 2.ddi / CHAP5 / PSP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-26  |  1.1 KB  |  53 lines

  1. /* PSP.C */
  2.  
  3. #include <stdlib.h>
  4. #include <dos.h>
  5. #include "tsr.h"
  6.  
  7. #define GET_PSP_DOS2   0x51
  8. #define GET_PSP_DOS3   0x62
  9. #define SET_PSP        0x50
  10.  
  11. static union  REGS regs;
  12.  
  13. /*****
  14. Function: GetPSP - returns current PSP
  15. *****/ 
  16. unsigned GetPSP(void)
  17. {
  18.     if (_osmajor == 2)
  19.     {   
  20.         if (! crit_err_ptr) /* must not have called InitInDos */
  21.             return 0;
  22.  
  23.         *crit_err_ptr = 0xFF;   /* force use of proper stack */ 
  24.         regs.h.ah = GET_PSP_DOS2; 
  25.         intdos(®s,®s);
  26.         *crit_err_ptr = 0;
  27.     }
  28.     else
  29.     {
  30.         regs.h.ah = GET_PSP_DOS3;
  31.         intdos(®s,®s);
  32.     }
  33.     
  34.     return regs.x.bx;
  35. }
  36.  
  37. /*****
  38. Function: SetPSP - sets current PSP
  39. *****/ 
  40. void SetPSP(unsigned segPSP)
  41. {
  42.     if (!crit_err_ptr)           /* must not have called InitInDos */
  43.         return;
  44.  
  45.     *crit_err_ptr = 0xFF;        /* force use of correct stack    */
  46.     regs.h.ah = SET_PSP;      
  47.     regs.x.bx = segPSP;          /* pass segment value to set     */
  48.  
  49.     intdos(®s,®s);
  50.     *crit_err_ptr = 0;
  51. }
  52.  
  53.