🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #13441

Re: varargs and register windows

#13441
From: csg
Date: Wed, 08 Apr 1987 22:27
26 lines
2098 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?

There are actually two problems: what to do when you run out of registers, and
what to do with objects that don't fit in registers (like structs). Pyramid
puts the first 13 scalars into the register stack; structs and parameters past
the 13th go onto the data stack. The <varargs.h> macros only permit sequential
scanning of the argument list, and are always passed the type of the argument
when an argument is extracted; hence it is easy for <varargs.h> to both count
the number of arguments and to determine whether a given argument is located
on the stack or in a register.

>...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?

It doesn't. Nor does work on machines that grow the stack from the bottom up,
or that push the arguments the "wrong" way (including many 8086 compilers).
Actually, you may be able to get away with it on machines that have memory-
addressable registers, if all the arguments are scalars or pointers. (I have
to do this on the Pyramid all the time. Meanwhile, we keep getting flames from
customers about "varargs being broken." No, <varargs.h> works fine. User code
that assumes how the machine passes parameters is what's broken. *SIGH*)

<csg>
Technical Details
Message-ID: <1859@pyramid.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watnot!watmath!clyde!rutgers!lll-lcc!pyramid!csg
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!lll-lcc!pyramid!csg
From: csg@pyramid.UUCP
Newsgroups: comp.arch
Subject: Re: varargs and register windows
Message-ID: <1859@pyramid.UUCP>
Date: Wed, 8-Apr-87 17:27:51 EST
Article-I.D.: pyramid.1859
Posted: Wed Apr  8 17:27:51 1987
Date-Received: Sat, 11-Apr-87 09:39:19 EST
References: <6575@allegra.UUCP>
Reply-To: csg@pyramid.UUCP (Carl S. Gutekunst)
Distribution: world
Organization: Pyramid Technology Corp., Mountain View, CA
Lines: 26