From: bdonor AT westnet DOT com (Brain Donor) Newsgroups: comp.os.msdos.djgpp Subject: Program runs in NT but not DOS. Date: Mon, 10 Nov 1997 09:01:48 GMT Organization: INTERNET AMERICA Lines: 80 Message-ID: NNTP-Proxy-Relay: library.airnews.net NNTP-Posting-Time: Mon Nov 10 03:03:32 1997 NNTP-Posting-Host: h238-198.whitman.albany.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I'm just starting with DJGPP and I wrote a small program that has a REALLY bad Mode13h putpixel in it. I compiled the program and it ran fine in NT, but in DOS it crashes with a segmentation fault (SIGSEGV). The code is below. Any ideas why? Also, how can I make the putpixel function inline. When I try, it won't compile. Thanks... #include #include #include #include #include short graphics_global_selector = _dos_ds; void main () { void putpixel (int, int, int); void setmode13h (); void setmode3h (); long int counter = 0; setmode13h (); while (!kbhit ()) { putpixel (rand () % 320, rand () % 200, rand () % 256); counter++; } setmode3h (); counter = 90000; cout << counter << endl; } void putpixel (int x, int y, int color) { asm( "movw _graphics_global_selector, %%es;" // This must be set so we can access our lower memory. It's some strange protected mode thing "xorl %%edi, %%edi;" // Clear out edi. This is an absolute pointer to our video memory. No need for segments!!! :) "movw %0, %%di;" // Load parameter zero (defined as x below) in di "movw %1, %%bx;" // Load parameter one (defined as y below) in bx "movl %%ebx, %%edx;" // Copy ebx into edx "shll $8, %%ebx;" // Do shifting for commutative math (y * 256) "shll $6, %%edx;" // (y * 64) "addl %%edx, %%ebx;" // Perform ((y * 256) + (y * 64)) to get y * 320 "addl %%ebx, %%edi;" // Add this to our x coordinate "addl $0xA0000, %%edi;" // Add the address of video RAM to edi to point to the offset in video memory. "movw %2, %%ax;" // Move color into ax "stosb;" // Perform stosb to store the color into video memory : :"g"(x), "g"(y), "g"(color) // Define x as %0, y as %1, color as %2 ); } void setmode13h () { __dpmi_regs reg; reg.x.ax = 0x13; __dpmi_int (0x10, ®); } void setmode3h () { __dpmi_regs reg; reg.x.ax = 0x03; __dpmi_int (0x10, ®); }