Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* ANSI-C style variadic functions on MIPS
@ 1990-01-05  8:52 Ken Raeburn
  1990-01-05 17:53 ` Dirk Grunwald
  0 siblings, 1 reply; 7+ messages in thread
From: Ken Raeburn @ 1990-01-05  8:52 UTC (permalink / 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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1990-01-09 20:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1990-01-05  8:52 ANSI-C style variadic functions on MIPS Ken Raeburn
1990-01-05 17:53 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox