Microsoft C far pointer dereferencing

Julian Cowley julian at uhccux.uhcc.Hawaii.Edu
Fri Aug 17 13:41:29 AEST 1990


In article <5843 at uceng.UC.EDU> mfinegan at uceng.UC.EDU (michael k finegan) writes:
>julian at uhccux.uhcc.Hawaii.Edu (Julian Cowley) writes:
>>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 ?

Unfortunately, no.  Moving the declaration outside of the
function body makes no difference in the behavior, even using
the large memory model.  I'm afraid that I have virtually no
knowledge of how Intel addressing works other than the
segment:offset concept, and even a quick scan through the
Microsoft manuals reveals none of the hocus-pocus assembly
language techniques that differentiate the memory models.
Since this is obviously moving outside the realm of comp.lang.c,
I'm going to repost to one of the comp.sys.ibm.pc.* groups.
Thanks to all who responded.

[ps. that was using quick c, not microsoft c proper...possible bug?]

julian cowley
university of hawaii at manoa
julian at uhccux.uhcc.hawaii.edu
julian at uhccux.bitnet



More information about the Comp.lang.c mailing list