Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!uw-beaver!uw-june!uw-entropy!dataio!bright
From: bright@Data-IO.COM (Walter Bright)
Newsgroups: comp.sys.ibm.pc
Subject: Re: How do I point to the frame buffer?
Keywords: C, far pointers, frame buffer,ibm pc
Message-ID: <1584@dataio.Data-IO.COM>
Date: 6 Jul 88 18:27:43 GMT
References: <2784@juniper.UUCP> <1391@lznv.ATT.COM>
Reply-To: bright@dataio.Data-IO.COM (Walter Bright)
Organization: Data I/O Corporation; Redmond, WA
Lines: 24

In article <1391@lznv.ATT.COM> psc@lznv.ATT.COM (Paul S. R. Chisholm) writes:
>The frame buffer starts at B800:0000, which would be 0xB8000 if the
>8088 had a linear address space.  It doesn't.  The right way to do this
>in MS or Turbo C is
	or Zortech C
>	#include 
>	far char * const Screen = MK_FP( 0xB800, 0 );
>(The "const" is optional; it tells the compiler that Screen is a
>constant, and that no one should be allowed to muck with it.)
> Comments?

Replace "const" with "volatile". All hardware device locations (except
ROM ones) should be "volatile", since they can be modified by an interrupt
routine (like a TSR). One example is the ^C that appears on the screen
when you type a control C.

Also, you've declared a . Try instead:
	volatile unsigned short far *Screen = ...
which is . The unsigned short
instead of char is because the display memory is actually organized as
words instead of bytes. The high byte is the attribute, the low byte
the character.
Note also that "const" and "volatile" are left-associative. "far" and
"near" are right-associative. Confusing? You bet!