Mail Archives: djgpp/1992/08/17/17:03:13
>I have some C-code which writes directly to screen memory on a
>Hercules card.
>Specifically, through a pointer initilized as
> unsigned char *screen = (unsigned char *)0xb8000000L;
>The code works under MSC, but fails under GCC. The error is a
>segmentation violation, which I more or less expected; is there a
>simple fix? (As is probably obvious, I'm not really familiar with
>programming in protected mode).
The above code is a VERY nonportable cast, and won't work in anything
other than a 16-bit DOS compiler. To get to a pointer to a seg/ofs
address, use this formula:
char *ptr = (char *)(0xe0000000 + seg * 16 + ofs);
Theoretically, the MK_FP() function should be used, but gcc doesn't
have one (but should).
>P.S. I reacently asked if the -O2 option is supported in GCC under
>MSDOS, but go no reply. Anyone know?
It is. Read the .tex files that come with djgcc222.zip.
- Raw text -