From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,1f81bffc4445958c,start X-Google-Attributes: gidfc89c,public X-Google-Thread: 10b612,1f81bffc4445958c,start X-Google-Attributes: gid10b612,public X-Google-Thread: 1164f8,1f81bffc4445958c,start X-Google-Attributes: gid1164f8,public X-Google-Thread: 1051a8,1f81bffc4445958c,start X-Google-Attributes: gid1051a8,public X-Google-ArrivalTime: 1991-07-10 22:52:11 PST Path: gmdzi!unido!mcsun!uunet!zephyr.ens.tek.com!uw-beaver!stowe.cs.washington.edu!pauld From: pauld@cs.washington.edu (Paul Barton-Davis) Newsgroups: comp.sys.mips,comp.sys.dec,comp.unix.ultrix,comp.unix.programmer Subject: is an nargs() for the MIPS architecture possible ? Message-ID: <1991Jul10.215707.18935@beaver.cs.washington.edu> Date: 10 Jul 91 21:57:07 GMT Sender: news@beaver.cs.washington.edu (USENET News System) Organization: Computer Science & Engineering, U. of Washington, Seattle Xref: gmdzi comp.sys.mips:1494 comp.sys.dec:24789 comp.unix.ultrix:46753 comp.unix.programmer:21817 Originator: pauld@stowe.cs.washington.edu Before I begin, I should point out that I am aware that any affirmative answer to this question will be highly non-portable, and very compiler-implementation dependent. Please do not waste network bandwidth to tell me or anyone else that what am I about to ask about cannot be done portably - I already know that, and that's why I'm posting. I have so far come across two implementations of an nargs() function. nargs() returns the number of arguments passed to the calling function. Hence, foo (int a, int b, int c) { printf ("%d\n", nargs()) } when called correctly will display "3". Both the implementations are rooted in knowing a lot about the compiler's calling conventions for the stack. They are also both for CISC architectures (Sequent Symmetry 386 and Sun 3 (68030)). Now I'm faced with porting some code which uses nargs() to a MIPS system. The rest of the port is done, and there are other methods I can think of to circumvent the need for nargs, but neverthless, outof intellectual curiosity, I'm wondering how difficult it would be to write such a function for a MIPS compiler ? I remember some stuff about how RISC compilers make much greater use of registers and so forth, but I know so little about this stuff, that I can't begin to guess. Would anyone like to comment ? E-mail would be preferred, but I'll watch these groups for a few days. - paul -- "When in some obscure country town, the farmers come together to a special town meeting, to express their opinion on some subject that is vexing the land, that I think is the true Congress, and the most respectable one that is ever assembled in the United States." - Thoreau