home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c005 / 5.ddi / C / UTCODPTR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-04-13  |  1.6 KB  |  64 lines

  1. /**
  2. *
  3. * Name        utcodptr -- Return the physical address of a function
  4. *
  5. * Synopsis    absval = utcodptr(ptr,pads);
  6. *
  7. *        unsigned long absval
  8. *                  The 20-bit physical address of the
  9. *                  specified function.
  10. *        void (*ptr)()      Pointer to the function whose address
  11. *                  is to be computed.
  12. *        ADS  *pads      An ADS structure containing the offset
  13. *                  and segment components of the physical
  14. *                  address of the function.
  15. *
  16. * Description    This function returns the physical address of the
  17. *        function pointed to by ptr.  The result is computed in
  18. *        two forms:  (1) as a 20-bit integer returned as an
  19. *        unsigned long; (2) as the split segment and offset in an
  20. *        ADS structure.
  21. *
  22. * Returns    absval          The 20-bit physical address of the
  23. *                  specified function.
  24. *        *pads          The offset and segment components of
  25. *                  the physical address of the function.
  26. *
  27. * Version    3.0 (C)Copyright Blaise Computing Inc. 1986
  28. *
  29. * Version    3.02 March 31, 1987
  30. *        Corrected calculation of return value.
  31. *        Rewrote to use makepv() in Lattice case.
  32. *
  33. **/
  34.  
  35. #include <butility.h>
  36.  
  37. #include <dos.h>              /* For FP_SEG, FP_OFF, and      */
  38.                       /* makepv().              */
  39.  
  40. unsigned long utcodptr(ptr,pads)
  41. int (*ptr)();
  42. ADS  *pads;
  43. {
  44. #if LAT300
  45.     makepv(ptr,&pads->r,&pads->s);
  46. #endif
  47.  
  48. #if MSC300
  49. #if LPROG
  50.     pads->s = FP_SEG(ptr);
  51.     pads->r = FP_OFF(ptr);
  52. #else                      /* Small code              */
  53.     unsigned cs,ss,ds,es;
  54.  
  55.     utsreg(&cs,&ss,&ds,&es);
  56.     pads->s = cs;
  57.     pads->r = (unsigned) ptr;
  58. #endif
  59. #endif
  60.  
  61.     return 0x0fffffL &
  62.     ((((unsigned long) pads->s) << 4) + (unsigned long) pads->r);
  63. }
  64.