Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: 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 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 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 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, works fine. User code that assumes how the machine passes parameters is what's broken. *SIGH*)