🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Charles Hannum Tue, 05 Jan 1993 09:52
Can't prevent asm() from popping 387 stack
#1585
Author: Charles Hannum
Date: Tue, 05 Jan 1993 09:52
35 lines
1155 bytes
I want to do something like the following:

double
atan2 (double y, double x)
{
  double temp;

  asm ("fpatan"
	: "+t" (temp)
	: "u" (y), "0" (x));

  return (temp);
}

The `fpatan' instruction pops one item from the top of the floating stack,
so there is only one left.  Unfortunately, GCC also seems to think it
should pop the second element on the stack:

	.file	"foo.c"
gcc2_compiled.:
.text
	.align 2
.globl _atan2
_atan2:
	fldl 12(%esp)
	fldl 4(%esp)
	fxch %st(1)
#APP
	fpatan
#NO_APP
	fstp %st(1)
	ret

I can't find any way to prevent this.  The only thing I've been able to do
is insert an extra `fld %st(0)' so it doesn't do any harm.
Re: Can't prevent asm() from popping 387 stack
#1593
Author: Charles Hannum
Date: Wed, 06 Jan 1993 08:43
9 lines
629 bytes
Oops.  I sent the wrong bit of C code.  This:

> 	: "+t" (temp)

should have been:

>	: "=t" (temp)

Any suggestions?
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads