Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!mcnc!ncsu!uvacs!edison!steinmetz!davidsen From: davidsen@steinmetz.UUCP (Davidsen) Newsgroups: net.lang.c,net.unix-wizards Subject: Re: arguments in registers Message-ID: <743@steinmetz.UUCP> Date: Wed, 14-May-86 13:11:37 EDT Article-I.D.: steinmet.743 Posted: Wed May 14 13:11:37 1986 Date-Received: Sun, 18-May-86 12:48:52 EDT References: <272@vecpyr.UUCP> <5302@alice.uUCp> <792@ccird2.UUCP> <155@cbmvax.cbmvax.cbm.UUCP> <1205@umcp-cs.UUCP> <109@ima.UUCP> Reply-To: davidsen@kbsvax.UUCP (Davidsen) Organization: GE CRD, Schenectady, NY Lines: 45 Xref: linus net.lang.c:8278 net.unix-wizards:15057 In article <109@ima.UUCP> johnl@ima.UUCP (John R. Levine) writes: >In article <1205@umcp-cs.UUCP> chris@maryland.UUCP (Chris Torek) writes: >>In article <155@cbmvax.cbm.UUCP> grr@cbmvax.UUCP (George Robbins) writes: >>>[Passing arguments in registers] would be fine if C had nested >>>procedures or inlines or something, but a disaster otherwise. >> The original "B" compiler for the GECOS operating system passed the first two arguments in registers and it worked fine. There are no inherent limitations, and it makes the code run much faster. Someone doing software metrics told me that 90% of the procedure calls in UNIX source code use <3 arguments, and running over about 50k lines of code by people at our site it looks as if that's true, even more so if you eliminate printf, which hopefully isn't called as often as the internal routines. There are three cases of action if the first N arguments are passed in registers: a) the values are never stored in memory and the procedure runs faster. b) the values are stored in memory when needed to preserve them during a procedure call, or when the registers are required for inline code. c) the compiler just stores the value in memory (stack of course) and goes on as if the calling program had done it. Note that in the worst case, the code to save the values has been moved from the calling routines to the called routine, making the code smaller, if not faster. In 1972 I produced a language called IMP from the original B, and it ran on the GE 600 series and the INtel 8080 (and could cross compile in either direction). If it can be done on an 8080, it can be done anywhere. The code was smaller and faster than that produced by any C compiler I've ever seen for the 8080, due in part to the frequent occurence of case (a) above, where the values were never stored. -- -bill davidsen seismo!rochester!steinmetz!--\ / \ ihnp4! unirot ------------->---> crdos1!davidsen \ / chinet! ---------------------/ (davidsen@ge-crd.ARPA) "Stupidity, like virtue, is its own reward"