/*
ROOTS.C (with apologies to Alex Haley)
Trace Your Ancestry!
Jim Kyle, 1990
*/

#include <stdio.h>
/* grr! different locations for _psp global variable! */
#ifdef __TURBOC__
#include <dos.h>
#else
#include <stdlib.h>
#endif

unsigned parent, self;

#define WORD(seg, ofs) \
     (*((unsigned far *) (((unsigned long)(seg)<<16) | (ofs))))

main ( void )
{ self = _psp;           /* start with own PSP value   */
  parent = WORD( self, 0x16 );
  do
    { printf("PID = %04X, PARENT = %04X\n", self, parent );
      self = parent;
    }
  while (( parent = WORD( self, 0x16 ) ) != self );
  return 0;
}
