Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!ima!johnl From: johnl@ima.UUCP (John R. Levine) Newsgroups: net.lang.c,net.unix-wizards Subject: Re: arguments in registers Message-ID: <109@ima.UUCP> Date: Tue, 6-May-86 11:36:51 EDT Article-I.D.: ima.109 Posted: Tue May 6 11:36:51 1986 Date-Received: Thu, 8-May-86 21:33:11 EDT References: <272@vecpyr.UUCP> <5302@alice.uUCp> <792@ccird2.UUCP> <155@cbmvax.cbmvax.cbm.UUCP> <1205@umcp-cs.UUCP> Reply-To: johnl@ima.UUCP (John R. Levine) Organization: Javelin Software Corporation Lines: 28 Xref: watmath net.lang.c:8886 net.unix-wizards:17970 Summary: passing args in registers is a wonderful idea and isn't hard 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. > >In fact, a compiler is free to optimise any function into inline code, Actually, you can always pass arguments in registers if you're smart about it. The compiler for the IBM RT/PC does. (A clever idea added after I stopped working on it.) The first few arguments to a procedure are always passed in registers, but space is left for them in the stack frame. If they aren't declared register in the routine, the routine's prolog saves them. Note that this saves code space, since you have one set of store instructions in the routine's prolog rather than replicating the code at each call. If the arguments are declared register, well, they're already in registers. As far as passing args to system calls in registers goes, the big win there is that the kernel's job of validating the arguments is made easier. If the args are in memory, the kernel has to make sure the address is valid, go through some address mapping calculations, possibly take page faults, and so forth. It's much easier if the user program puts the args in registers, since then the validation is done for free by hardware. -- John R. Levine, {ihnp4 | decvax | cbosgd | harvard | yale }!ima!johnl Levine@YALE.EDU The opinions expressed above are those of a 12-year-old hacker who has broken into my account and not those of any person or organization.