9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Charles Forsyth <forsyth@terzarima.net>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] debugging help asked for
Date: Tue, 22 May 2007 11:43:41 +0100	[thread overview]
Message-ID: <49816f71a7fa67a70669172ba3195886@terzarima.net> (raw)
In-Reply-To: <ACCF003CBA3D09458207DB0CB86AD17D7402F5@XMAIL.asuch.cas.cz>

> I compiled successfully a code ported from gcc/linux that runs OK there. However, I'm getting stack underflow error when running it under Plan 9.

that often happens when a function that returns double has no external declaration in scope where it's used,
and it gets the default type of int, so the result on the floating-point stack is not popped at the point of call.
that applies even when it's called for side-effect.

double	f(int);

void
g(void)
{
	f(3);
}

h% 8c -S db.c
	TEXT	g+0(SB),0,$8
	MOVL	$3,AX
	MOVL	AX,(SP)
	CALL	,f+0(SB)
	FMOVDP	F0,F0
	RET	,
	END	,

note the P (pop) suffix on FMOVDP

of course, the compiler will have complained about the missing
declaration unless you've told it otherwise.



  parent reply	other threads:[~2007-05-22 10:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-21 11:32 cej
2007-05-21 13:36 ` Richard Miller
2007-05-22 10:43 ` Charles Forsyth [this message]
2007-05-22 10:45   ` Charles Forsyth
2007-05-22 11:03     ` Charles Forsyth

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=49816f71a7fa67a70669172ba3195886@terzarima.net \
    --to=forsyth@terzarima.net \
    --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).