JC> #include
JC> int main(void) {
JC> int _far *screen = (int _far *)MK_FP(0xb800, 0);
JC> for ( int i=0; i<(80*25); i++)
JC> *screen++ = ' ';
JC> return 0;
JC> }
JC> I intend that it clear the screen. As long as I compile without
JC> optimization, it does exactly that. _However_ if I tell Microsoft
JC> VC++ 1.52 to use maximum optimization, it does absolutely _nothing_.
I'll have to try that. Kinda lame...
JC> The problem is that the compiler has "noticed" that I'm not "using"
JC> any of the values I write into `*screen', so it simply doesn't write
JC> them there anymore. If I change the declaration of `screen' to:
JC> int _far volatile *screen /* ... */;
JC> It clears the screen regardless of the level of optimization I decide
JC> to use.
JC> (disclaimer: this is demo code only. It't not intended for real use.
JC> It definitely _won't_ work if you have a monochrome card installed.
JC> If you have a color card installed, it's likely to cause a nuclear
JC> catastrophe.)
Don't worry, I have routines writing directly to video memory. No
damage is done if you point to the wrong address. At worst you'll hang
the machine real bad...
Gerry Danen (gdanen@accessweb.com) C+Net BBS @ 403-477-9545
http://www.geocities.com/SiliconValley/Way/9823
2 years, 140 days, 15 hours, 52 minutes, and 0 seconds until January 1, 2000.
... There are 3 kinds of people: Those who can count & those who can't.
--- Maximus 3.01
---------------
* Origin: C+Net BBS. Programming & Networking. (1:342/1017)
|