🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #52066

asm() constraints

#52066
From: Brad Huntting
Date: Fri, 26 Feb 1993 06:21
34 lines
1690 bytes
I'm getting very confused trying to implement atan2(x,y) with an
asm() statement on a bsd386 system (using gcc-2.2.2).

The 387 instruction "fpatan" requires input operands x and y to be in
on the top of the floating point register stack in %st and %st(1)
respectivly.  The output operand will be placed in %st after the stack
has been poped (i.e. %st(2) will end up in %st(1) afterwards.

From what I can gleam from the documentation, this should look
_something_ like this:

	#define atan2(x,y) \
	({ \
		double _x = (x), _y = (y), _z; \
		asm const ( \
			"fpatan" \
			: "=f" (_z) \
			: "0" (_x), "f" (_y) \
			: "2" \
		); \
		_z; \
	})

But isn't quite correct.  Do I need to specify registers in the
declaration of _x and _y?  How do I tell it that the stack will be
poped?  Do I need to add something to the last field in the asm() to
tell it that the floating point status word will be clobbered?


very worried,
brad
	huntting@glarp.com

   < <  zippy is so confused  * *
Technical Details
Message-ID: <1993Feb26.062103.20601@advtech.uswest.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!howland.reston.ans.net!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!cherokee!huntting

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,6ef6a338c52a498a,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-02-25 22:21:03 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!howland.reston.ans.net!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!csn!cherokee!huntting
From: huntting@advtech.uswest.com (Brad Huntting)
Subject: asm() constraints
Message-ID: <1993Feb26.062103.20601@advtech.uswest.com>
Sender: news@advtech.uswest.com (Radio Free Boulder)
Nntp-Posting-Host: futureworld.advtech.uswest.com
Organization: U S WEST Advanced Technologies
Date: Fri, 26 Feb 1993 06:21:03 GMT
Lines: 34