home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 1.ddi / CLIB1.ZIP / PEEK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  2.3 KB  |  72 lines

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