home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!aries.scs.uiuc.edu!mcdonald
- From: mcdonald@aries.scs.uiuc.edu (J. D. McDonald)
- Subject: Re: Peek/Poke in C
- References: <BV5XVB5w165w@blackwlf.gwinnett.com> <pal.724673747@regent.e-technik.tu-muenchen.de> <BzGIDn.Ho4@news.cso.uiuc.edu>
- Message-ID: <mcdonald.621@aries.scs.uiuc.edu>
- Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
- Organization: UIUC SCS
- Date: Fri, 18 Dec 1992 14:36:14 GMT
- Lines: 55
-
- In article <BzGIDn.Ho4@news.cso.uiuc.edu> cad28526@uxa.cso.uiuc.edu (Chuck Douglas) writes:
-
- >pal@regent.e-technik.tu-muenchen.dbp.de (Peter Loibl) writes:
-
- >>ericwebb@blackwlf.gwinnett.com (eric webb) writes:
-
- >>>Hi again.. does anyone know how to do equivalent of BASIC's PEEK & POKE
- >>>statements in C?
-
- >>I am sorry for my ignorance, but what are PEEK and POKE doing? If you
- >>describe their task, then this would be lots of help for all the
- >>"C-Gurus" here.
-
- >PEEK and POKE are used in Applesoft BASIC to look at (PEEK) the contents
- >of or put (POKE) a value in to a specific memory address. I really
- >don't believe that there is anything analogous to it in C. At least
- >nothing that would serve the use it does in Applesoft.
-
-
- Peek and Poke exist (existed) in far more than just one particular Basic.
- They are (were) near ubiquitous. For example, there were in PDP-11
- RT11 **system** subroutines (they were not, however, system **calls**,
- as they did not call the OS) called IPEEK and IPOKE, not to mention ISPY.
-
- And, of course, the original poster had the correct answer! These calls
- are used or OS sorts of things, e.g. writing to device registers.
- Any subroutine written in C for the purpose of being a device driver for
- a machine with memory mapped IO or IO vectors will need them.
-
- AND FOLKS, PLEASE, don't go blathering about "portability". It makes you
- look silly. If the address of something on you computer is 13556, that's
- what it is, and you have no choice about using it.
-
- The answer is "if you can do it at all in C, you cast the address to
- a pointer of the proper sort and access that pointer ...
-
- *(char _far *)(13556) = 17;
-
- or value = *(char _far *)(13556); "
-
- where the _far implies you are running a PC in 16 bit mode.
-
- On some computers you can do this only if the address is within some
- annointed range. But remember, you purists out there, this likely **IS**
- kernal code. You likely **can** address anywhere you want to!
-
-
- Doug McDonald
-
-
-
-
-
-
-
-