delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/18/18:15:28

From: "Mr R. Hopkins" <r.hopkins*@ic.ac.uk>
Newsgroups: comp.os.msdos.djgpp,comp.os.linux.misc
Subject: Re: Floating point + inline assembly + C =?
Date: Wed, 17 Dec 1997 15:28:06 +0000
Organization: Electronic Engineering Dept. Imperial College
Lines: 49
Message-ID: <3497EF86.41C67EA6@ic.ac.uk>
References: <349675F3 DOT 2781E494 AT ic DOT ac DOT uk> <m267opnqu3 DOT fsf AT planet DOT net>
NNTP-Posting-Host: pint.ee.ic.ac.uk
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Josh Vanderhoof wrote:
> 
> "Mr R. Hopkins" <r.hopkins*@ic.ac.uk> writes:
> 
> > Hi there, I have an interesting problem:
> > I am trying to write a short program which has some inline asm in gcc
> > (either gcc on Linux or DJGPP on DOS). The problem I am having is
> > passing a couple of floating point variables to the __asm__ part. What
> > appears to happen when I use the suggested (by gcc info) method of:
> > __asm__ (
> >       " fblahblah %1 \n"
> >       " faddstuff %%st(2), %%st(0) \n"
> >       " fldd %2 \n"
> >       " fstd %0 \n" /* etc. etc. */
> >       : "=r" (output_var)
> >       : "f" (input1), "f" (input2)
> >       : "%st" /* clobbers */
> > );
> >
> > This approach does not work, since in lines (2)and (3) above notice how
> > the floating point stack gets shuffled about. This causes the input
> > param %2 to be further down the stack than expected, and so the value
> > of %st which gcc inserts for param %2 is now incorrect.
> > As a consequence, the code produces unexpecte (an undesireable) answers.
> 
> Passing floating point parameters to asm on the x86 isn't very well
> documented in the info file.  Get the source to gcc and read the
> comment at the beginning of reg-stack.c.  That explains how gcc
> adjusts the fp stack according to the asm args.
> 
> --
> Josh Vanderhoof (joshv AT planet DOT net)

Thanks very much, I will try it!
-- 
Hoppy

To reply please remove the * from my email address

http://www.geocities.com/CapeCanaveral/5003/
is the place to go if you ever wanted to know how to write fractal
programs or make 3D programs

_____

Polite notice to people who obtain email addresses from usenet postings
so that they can send innocent people junk mail

GO KILL YOURSELVES YOU GITS

- Raw text -


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