From: raeburn@athena.mit.edu (Ken Raeburn)
Subject: ANSI-C style variadic functions on MIPS
Date: 5 Jan 90 08:52:05 GMT [thread overview]
Message-ID: <1990Jan5.085205.12473@athena.mit.edu> (raw)
(I apologize if this issue has already been raised, but I haven't been
reading these newsgroups.)
How does one properly implement <stdarg.h> for a PMAX? (Or any
MIPS-based system, for that matter.)
According to "MIPS RISC Architecture" by Kane, the first few arguments
to a function are passed in registers, if their types fit certain
constraints.
If the first argument to a function is assumed to be some floating
point type, the possibilities for the argument locations boil down to:
arguments registers (f1->$f12 always)
f1, f2, ... f2->$f14, remainder on stack
f1, n1, ... n1->$6, remainder [elsewhere]
(Arguments following N1 don't really matter, I think.)
If a function is declared as:
void foo (double d, ...);
then where does it find the next argument? Is it in $6 or $f14? Even
the simplest mechanisms I can imagine that conform to the description
above involve a fair amount of compiler support, which isn't being
provided so far as I can see.
The best working alternative I see is that arguments which may have
different types get treated as type 'N' arguments in the table above,
even if they are floating-point values. This isn't what is described
in Kane's book, but I don't see any other way to make it work. (This
also is not what the MIPS compiler does, but a simple test file shows
that the stdarg use simply fails, so....)
(Before someone points it out, I am aware that the compiler on the
PMAX does not claim to be ANSI compliant.)
Anybody know any "official" answers?
-- Ken
next reply other threads:[~1990-01-05 8:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-01-05 8:52 Ken Raeburn [this message]
1990-01-05 17:53 ` ANSI-C style variadic functions on MIPS Dirk Grunwald
1990-01-06 6:28 ` Ken Raeburn
1990-01-06 19:51 ` David Lai
1990-01-08 4:15 ` Ken Raeburn
1990-01-09 20:07 ` David Lai
1990-01-08 14:31 ` Jim Gettys
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox