delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/11/11/15:17:05

Date: Tue, 11 Nov 1997 12:16:24 -0800 (PST)
Message-Id: <199711112016.MAA18258@adit.ap.net>
Mime-Version: 1.0
To: bdonor AT westnet DOT com (Brain Donor), djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Program runs in NT but not DOS.

At 09:01  11/10/1997 GMT, Brain Donor wrote:
>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? 
Yes, see below.
> Also, how can I make the putpixel
>function inline.  When I try, it won't compile.  Thanks...
You have to define a function prior to using it to make it be able to be
inlined. Example:
inline void putpixel(...) { ... }

int main(...) 
{
 putpixel(...); 
}
[snipped]
>      "movw _graphics_global_selector, %%es;"  // This must be set so
>we can access our lower memory.  It's some strange protected mode
>thing
[snipped]
>      "movw %1,    %%bx;"                      // Load parameter one
>(defined as y below) in bx
You don't tell the compiler which registers you are using. You have to add a
third colon to your asm constraints and list the registers which get
clobbered. Example:
asm("..." : /* Inputs */ : /* Outputs */ : "eax","ebx" );
See the Extended Asm node of the GCC docs for more info.
Also, this feature is not smart enough to know about %es being clobbered,
even if you add it to the clobber-list. You have to save and restore it
explicitly, since GCC uses it. You might use %fs instead, since nothing uses
it except _farns*() functions. Then you don't have to save it.

I'm not sure why this worked under NT; maybe you used different compiling
options and/or just got lucky.

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019