Date: Mon, 17 Aug 92 16:58:01 EDT From: DJ Delorie To: ronis AT ronis DOT chem DOT mcgill DOT ca Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Herculese Memory >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.