home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 5.ddi / C / UTABSPTR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-08-05  |  1.8 KB  |  74 lines

  1. /**
  2. *
  3. * Name        utabsptr -- Return the absolute value of a pointer
  4. *
  5. * Synopsis    absval = utabsptr(ptr,pads);
  6. *
  7. *        unsigned long absval  The absolute address represented by
  8. *                  the specified pointer, ptr.
  9. *        char *ptr      The pointer whose absolute address is
  10. *                  computed.
  11. *        ADS  *pads      An ADS structure containing the offset
  12. *                  and segment of the absolute address
  13. *                  pointed to by pointer.
  14. *
  15. * Description    This function returns the absolute address of the
  16. *        location pointed to by ptr.  The result is returned as
  17. *        an unsigned long integer.  A segment/offset address of
  18. *        the pointer is returned in the ADS structure.
  19. *
  20. *        For large data models, pointers are 32-bit quantities
  21. *        representing both segment and offset, but for small data
  22. *        models, pointers are offsets within the default data
  23. *        segment.
  24. *
  25. * Returns    absval          The absolute address of *ptr
  26. *        *pads          An ADS variable representing the
  27. *                  location of *ptr.
  28. *
  29. * Version    3.0 (C)Copyright Blaise Computing Inc.    1984, 1985, 1986
  30. *
  31. **/
  32.  
  33. #include <butility.h>
  34.  
  35. #if MSC300 & LDATA
  36. #include <dos.h>               /* For FP_SEG, FP_OFF symbols   */
  37. #endif
  38.  
  39. unsigned long utabsptr(ptr,pads)
  40. char *ptr;
  41. ADS  *pads;
  42. {
  43.     unsigned long absptr;
  44.  
  45. #if LDATA
  46. #else
  47.     unsigned      cs,ss,ds,es;
  48. #endif
  49.  
  50. #if CI201A & LDATA
  51.     unsigned long ptrtoabs();
  52. #endif
  53.  
  54.     absptr = (unsigned long)ptr;
  55. #if LDATA
  56. #if CI201A
  57.     absptr = ptrtoabs(ptr);
  58. #endif    /* CI201A */
  59. #if MSC300
  60.     pads->s = FP_SEG(ptr);
  61.     pads->r = FP_OFF(ptr);
  62. #else    /* not MSC300 */
  63.     pads->s = (unsigned)((absptr & 0xffff0L) >> 4L);
  64.     pads->r = (unsigned)(absptr & 0xfL);
  65. #endif    /* MSC300 */
  66. #else    /* not LDATA */
  67.     utsreg(&cs,&ss,&ds,&es);
  68.     pads->s = ds;
  69.     pads->r = (unsigned)ptr;
  70. #endif    /* LDATA */
  71.  
  72.     return(absptr);
  73. }
  74.