home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!olivea!charnel!sifon!thunder.mcrcim.mcgill.edu!sobeco!philmtl!ray
- From: ray@philmtl.philips.ca (Ray Dunn)
- Newsgroups: comp.lang.c
- Subject: Re: Peek/Poke in C
- Message-ID: <1992Dec20.011645.17632@philmtl.philips.ca>
- Date: 20 Dec 92 01:16:45 GMT
- References: <BV5XVB5w165w@blackwlf.gwinnett.com> <behrenss.724679975@hphalle6>
- Organization: Not Philips.
- Lines: 32
-
- In refd article, behrenss@Informatik.TU-Muenchen.DE (Soenke Behrens) 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?
- >
- >Very implentation-specific. Some architectures allow something along
- >the lines of
- >
- >char *address;
- >
- >address = 0x678090;
- >*address = 80; /* poke $678090,80 */
- >printf ("And peek gives us: %d\n",*address);
-
- _All_ architectures allow the above constructions. What is architecture
- specific is the range of numeric addresses which are meaningful, and
- whether the addresses are absolute or relative to some base or segment
- start address. This is actually no different from PEEK and POKE in the
- general case.
-
- There are even architectures in which you can address _registers_ in this
- way, and of course if running on hardware that has memory mapped I/O, the
- I/O ports can be accessed using the same technique too.
-
- On the PC you can create an absolute memory address so long as you define
- the pointer to be of type far. If you don't, then in small or medium model
- the address is taken to be relative to the start of the data segment. Far
- pointers can be created into other segments by using (in MSC) the FP_SEG
- and FP_OFF macros.
- --
- Ray Dunn at home | Beaconsfield, Quebec | Phone: (514) 630 3749
- ray@philmtl.philips.ca | ray@cam.org | uunet!sobeco!philmtl!ray
-