home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / PEEK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  2.0 KB  |  71 lines

  1. /*-------------------------------------------------------------------------*
  2.  * filename - peek.c
  3.  *
  4.  * function(s)
  5.  *        peek  - examines memory location
  6.  *        peekb - examines memory location
  7.  *--------------------------------------------------------------------------*/
  8.  
  9. /*
  10.  *      C/C++ Run Time Library - Version 5.0
  11.  *
  12.  *      Copyright (c) 1987, 1992 by Borland International
  13.  *      All Rights Reserved.
  14.  *
  15.  */
  16.  
  17.  
  18. #include <dos.h>
  19. #undef  peek
  20. #undef  peekb
  21.  
  22. /*---------------------------------------------------------------------*
  23.  
  24. Name            peek - examines memory location
  25.  
  26. Usage           int peek(unsigned segment, unsigned offset);
  27.  
  28. Related
  29. functions usage char peekb(unsigned segment, unsigned offset);
  30.  
  31. Prototype in    dos.h
  32.  
  33. Description     peek and peekb examine the memory location addressed
  34.                 by segment:offset.
  35.  
  36.                 If these routines are called when dos.h has been included,
  37.                 they will be treated as macros that  expand to in-line code.
  38.                 If you don't include dos.h (or if you do include it and
  39.                 #undef the routines) you will get the functions rather
  40.                 than the macros.
  41.  
  42. Return value    peek and peekb return the value stored at the
  43.                 memory location segment:offset. peek returns a word, and
  44.                 peekb returns a byte.
  45.  
  46. *---------------------------------------------------------------------*/
  47. int peek(unsigned segment, unsigned offset)
  48. {
  49.         _ES = segment;
  50.         return(* (int _es *) offset);
  51. }
  52.  
  53.  
  54. /*---------------------------------------------------------------------*
  55.  
  56. Name            peekb - examines memory location
  57.  
  58. Usage           #include <dos.h>
  59.                 char peekb(unsigned segment, unsigned offset);
  60.  
  61. Prototype in    dos.h
  62.  
  63. Description     see peek above
  64.  
  65. *---------------------------------------------------------------------*/
  66. char peekb(unsigned segment, unsigned offset)
  67. {
  68.         _ES = segment;
  69.         return(* (unsigned char _es *) offset);
  70. }
  71.