9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: rog@vitanuova.com
To: 9fans@cse.psu.edu
Subject: Re: [9fans] fp: stack underflow error
Date: Thu,  1 Jul 2004 20:24:23 +0100	[thread overview]
Message-ID: <d66164ffbf07b27c99685ea41599f1a3@vitanuova.com> (raw)
In-Reply-To: <b974470c3e357a7efd16b8345fb68e94@orthanc.cc.titech.ac.jp>

> I encountered a "sys: fp: stack underflow" error in my program.

looks like a compiler bug.

here's a simpler version of the code that does the same thing.
who'd've thought that a2b() would generate such
convoluted code? what's that comparison for?

	TEXT	a2b+0(SB),0,$12
	MOVL	tb+4(FP),CX
	SUBL	fb+0(FP),CX
	MOVL	CX,.safe+-4(SP)
	FMOVL	.safe+-4(SP),F0
	CMPL	CX,$0
	JGE	,2(PC)
	FADDD	$(4.29496729600000000e+09),F0
	FMULD	dis+8(FP),F0
	FSTCW	,.safe+-8(SP)
	MOVW	$3967,.safe+-6(SP)
	FLDCW	.safe+-6(SP),
	FMOVLP	F0,.safe+-4(SP)
	FLDCW	.safe+-8(SP),
	MOVL	.safe+-4(SP),AX
	RET	,

#include <u.h>
#include <libc.h>
int
a2b(int fb, uint tb, double dis)
{
	return (tb - fb)*dis;
}

void
main(void)
{
	a2b(1, 0, 65);
	a2b(1, 0, 66);
}



  parent reply	other threads:[~2004-07-01 19:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-01  4:50 YAMANASHI Takeshi
2004-07-01  8:55 ` Kenji Okamoto
2004-07-01 19:24 ` rog [this message]
2004-07-01 20:32   ` Charles Forsyth
2004-07-01 20:38     ` boyd, rounin
2004-07-02  9:34   ` Charles Forsyth
2004-07-02 10:25     ` Geoff Collyer
2004-07-02 10:53       ` Charles Forsyth
2004-07-02  0:35 YAMANASHI Takeshi
2004-07-02  1:02 ` Kenji Okamoto
2004-07-02  1:04   ` Kenji Okamoto
2004-07-02  1:05     ` Kenji Okamoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d66164ffbf07b27c99685ea41599f1a3@vitanuova.com \
    --to=rog@vitanuova.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).