🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #13428

Re: varargs and register windows

#13428
From: sjc
Date: Tue, 07 Apr 1987 19:44
26 lines
1749 bytes
In article <6575@allegra.UUCP>, kak@allegra.UUCP (Keith Kelleman) writes:
> How do machines with register windows, e.g. RISC I/II,
> handle variable length argument lists?...
> Also, in C, its common practice to treat the passed arguments
> as memory, i.e. pointing at them with an (int *) and then using
> (++) to walk through them as an array.
> How does this work if the arguments are in registers?
> 
> Do MIPS, Clipper, and the new AMD micro have the same problems?

I can answer regarding MIPS: variable-length argument lists work fine if you
use the familiar "varargs.h" macro package (say "man varargs", or see the
draft ANSI C standard), but not if you step through the arguments with "++".
Our compiler tries fairly hard to warn you if it suspects your code uses the
latter method.

The issue is not really the use of registers (we store an argument into its
"home" in stackframe memory anyway if you take its address), but is more a
matter of alignment within the stackframe. In any case, "varargs.h" takes
care of everything.

The "++" method causes trouble on numerous machines, quite apart from the use
of registers; imagine, for example, what happens if the machine merely grows
the stack in the "wrong" direction.
-- 
...decwrl!mips!sjc						Steve Correll
Technical Details
Message-ID: <993@mips.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!sri-spam!ames!lll-lcc!pyramid!prls!mips!sjc
References: <6575@allegra.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!sri-spam!ames!lll-lcc!pyramid!prls!mips!sjc
From: sjc@mips.UUCP
Newsgroups: comp.arch
Subject: Re: varargs and register windows
Message-ID: <993@mips.UUCP>
Date: Tue, 7-Apr-87 14:44:57 EST
Article-I.D.: mips.993
Posted: Tue Apr  7 14:44:57 1987
Date-Received: Fri, 10-Apr-87 06:07:34 EST
References: <6575@allegra.UUCP>
Lines: 26