home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l440 / 2.ddi / CHAP3 / ROOTS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-25  |  631 b   |  30 lines

  1. /*
  2. ROOTS.C (with apologies to Alex Haley)
  3. Trace Your Ancestry!
  4. Jim Kyle, 1990
  5. */
  6.  
  7. #include <stdio.h>
  8. /* grr! different locations for _psp global variable! */
  9. #ifdef __TURBOC__
  10. #include <dos.h>
  11. #else
  12. #include <stdlib.h>
  13. #endif
  14.  
  15. unsigned parent, self;
  16.  
  17. #define WORD(seg, ofs) \
  18.      (*((unsigned far *) (((unsigned long)(seg)<<16) | (ofs))))
  19.  
  20. main ( void )
  21. { self = _psp;           /* start with own PSP value   */
  22.   parent = WORD( self, 0x16 );
  23.   do
  24.     { printf("PID = %04X, PARENT = %04X\n", self, parent );
  25.       self = parent;
  26.     }
  27.   while (( parent = WORD( self, 0x16 ) ) != self );
  28.   return 0;
  29. }
  30.