Path: utzoo!dciem!nrcaer!scs!spl1!laidbak!att!westmark!dave From: dave@westmark.UUCP (Dave Levenson) Newsgroups: comp.lang.c Subject: Re: Microsoft "C" How to Peek and Poke? Message-ID: <240@westmark.UUCP> Date: 11 Jul 88 01:29:10 GMT Article-I.D.: westmark.240 References: <1148@cod.NOSC.MIL> Organization: Westmark, Inc., Warren, NJ, USA Lines: 38 In article <1148@cod.NOSC.MIL>, ammons@cod.UUCP writes: > Question: ... > How can a Microsoft "C" programmer read and write the contents of > a particular memory location in an IBM-PC compatble (ie. Zenith Z-248)? > That is, how can you peek and poke in Microsoft C? While you could write peek() and poke() functions in MS-C, you can more efficiently de-reference a far pointer to the absolute memory location inline. For example: Suppose we want to update absolute location B800:0000 (which is the upper left character position on the screen, with the video adaptor I'm using) and put a character there. We can write: void showit(c) char c; { char far *video; FP_SEG(video) = 0xb800; /* initialize the pointer */ FP_OFF(video) = 0; *video = c; /* update the location */ return; } The above function uses a Microsoft extension of C (it's available on some other Intel-based compilers, as well): the far pointer. This is a pointer consisting of a segment and offset, that is a "natural object" for the Intel architecture. -- Dave Levenson Westmark, Inc. The Man in the Mooney Warren, NJ USA {rutgers | att}!westmark!dave