home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / c / 18853 < prev    next >
Encoding:
Internet Message Format  |  1992-12-24  |  1.3 KB

  1. Path: sparky!uunet!spool.mu.edu!uwm.edu!linac!att!cbnewsm!cbnewsl!att-out!rutgers!mcdhup!src4src!wozzle!alane
  2. From: alane@wozzle.linet.org (J. Alan Eldridge)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Peek/Poke in C
  5. Message-ID: <mLF0VB1w165w@wozzle.linet.org>
  6. Date: 24 Dec 92 00:08:57 GMT
  7. References: <pal.724673747@regent.e-technik.tu-muenchen.de>
  8. Organization: Disorganization
  9. Lines: 27
  10.  
  11. pal@regent.e-technik.tu-muenchen.dbp.de (Peter Loibl) writes:
  12.  
  13. > ericwebb@blackwlf.gwinnett.com (eric webb) writes:
  14. > >Hi again.. does anyone know how to do equivalent of BASIC's PEEK & POKE
  15. > >statements in C?
  16. > I am sorry for my ignorance, but what are PEEK and POKE doing? If you
  17. > describe their task, then this would be lots of help for all the
  18. > "C-Gurus" here.
  19.  
  20. peek and poke are to access absolute memory addresses under DOS.
  21.  
  22. most DOS compilers support them either through intrinsic (builtin)
  23. functions or macros that call builtin functions.
  24.  
  25. For example, TopSpeed C++ does this:
  26.  
  27. #define poke(a,b,c)  (*((int  far *)MK_FP((a),(b))) = (int)(c))
  28. #define pokeb(a,b,c) (*((char far *)MK_FP((a),(b))) = (char)(c))
  29. #define peek(a,b)    (*((int  far *)MK_FP((a),(b))))
  30. #define peekb(a,b)   (*((char far *)MK_FP((a),(b))))
  31.  
  32. where a is a segment (or selector), b is an offset, and c is a value.
  33.  
  34. alane@wozzle.linet.org (J. Alan Eldridge)
  35. Fido: The University of Walamaloo 1:272/38.473
  36.