Path: utzoo!censor!geac!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!mailrus!iuvax!uceng!mfinegan From: mfinegan@uceng.UC.EDU (michael k finegan) Newsgroups: comp.lang.c Subject: Re: Microsoft C far pointer dereferencing Message-ID: <5843@uceng.UC.EDU> Date: 16 Aug 90 21:30:04 GMT References: <9031@uhccux.uhcc.Hawaii.Edu> Organization: Univ. of Cincinnati, College of Engg. Lines: 25 julian@uhccux.uhcc.Hawaii.Edu (Julian Cowley) writes: >Ok, I've read the articles concerning the use of (void far *) in >Microsoft C, but I still can't figure out why the pointer in >following piece of code won't dereference. What I'm trying to >do is access the MCGA screen at A000:0000, in case there is a >better way to do this... >PutPixel (int x, int y, unsigned char c) >{ > unsigned char far *mem; > FP_SEG (mem) = 0xa000; > FP_OFF (mem) = 320 * y + x; > *mem = c; /* <-- this line gives a run-time error */ >} If you look at the manual page again, it says the use of FP_*** is library (i.e. memory model) dependent. For small and medium models, these macros will only work if the pointer mem is in the default data segment. You have it on the stack (subroutine automatic variables) - is that the problem ? - Mike mfinegan@uceng.UC.EDU