🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #1976

Re: Finding the MCGA in Quick C 2.01

#1976
From: Jian Hu
Date: Thu, 23 Aug 1990 11:13
39 lines
2045 bytes
julian@uhccux.uhcc.Hawaii.Edu (Julian Cowley) writes:

>I've just come over from comp.lang.c where this request drew a
>blank expression from the members of the newsgroup.  What I'm
>trying to do is access the MCGA screen at A000:0000.  Here was
>my first attempt:

>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 */
>}

>The commented line caused run-time error R6013: illegal far
>pointer use.  (Unfortunately, I do not have the manuals to look
>up the cause, even though this is a legitimate copy of Quick
>C.)  The help page for the FP_* macros says that the macros
>won't work under certain conditions in small and medium models,
>but this happens in large model also.

I`ve just tried the above code segment on QC2.0 and got the same result, 
which surprised me because one of my applications used the same technique 
to adress high memory. After some comparison to my old code, I found the
ridiculous answer (or one of them): Change the commented line to:

	(*mem++) = c;

Of couse you`ll have to decrease mem to keep the value. Studying the machine
code shows that this line straightly assigns c to the location mem points to.
When the original line is used, the machine code checks the segment value
of mem (A000) against two global variables __asegh and __aseglo. If 
__aseglo<=FP_SEG(mem)<__asegh, an error is generated.

This doesn`t seem to me like a compiler error, does it? And I would also like 
to know why.
Technical Details
Message-ID: <162@prodix.liu.se>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!liuida!prodix!jian
References: <9046@uhccux.uhcc.Hawaii.Edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!liuida!prodix!jian
From: jian@prodix.liu.se (Jian Hu)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Finding the MCGA in Quick C 2.01
Message-ID: <162@prodix.liu.se>
Date: 23 Aug 90 11:13:35 GMT
References: <9046@uhccux.uhcc.Hawaii.Edu>
Organization: Dept of Mechanical Engineering, Univ of Linkoping, Sweden
Lines: 39