Xref: utzoo comp.sys.mips:396 comp.sys.dec:2409 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mit-eddie!bloom-beacon!athena.mit.edu!raeburn From: raeburn@athena.mit.edu (Ken Raeburn) Newsgroups: comp.sys.mips,comp.sys.dec Subject: ANSI-C style variadic functions on MIPS Keywords: stdarg Message-ID: <1990Jan5.085205.12473@athena.mit.edu> Date: 5 Jan 90 08:52:05 GMT Sender: news@athena.mit.edu (News system) Reply-To: Ken Raeburn Organization: MIT Project Athena Lines: 41 (I apologize if this issue has already been raised, but I haven't been reading these newsgroups.) How does one properly implement 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