Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 8/28/84; site lll-crg.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!umcp-cs!gymble!lll-crg!brooks From: brooks@lll-crg.ARPA (Eugene D. Brooks III) Newsgroups: net.lang.c Subject: Re: number of arguments function for 4.1bsd VAX cc(1) -- TYPO FIX Message-ID: <408@lll-crg.ARPA> Date: Mon, 25-Feb-85 13:09:58 EST Article-I.D.: lll-crg.408 Posted: Mon Feb 25 13:09:58 1985 Date-Received: Wed, 27-Feb-85 21:14:29 EST References: <271@oliveb.UUCP> Organization: Lawrence Livermore Labs, CRG group Lines: 26 > int > numargs() > { > asm(" clrl r1"); > asm(" subb3 8(fp),$92,r1"); > asm(" ashl $-2,r1,r0"); /* changed $2 to $-2 */ > } I can't fathom how this one works. Here is the one I use for all Vax PCC ports. As the stack frame for the Vax is hardwired by the call instruction it should work on all vax C compilers that use CALLS for their routine linkage. int getnargs() { asm(" movl 8(fp),r0"); /* Move the AP of the caller into r0. */ asm(" movzbl (r0),r0"); /* The arg count is a byte at (AP). */ #ifdef lint return(0); /* Lets keep lint useful. */ #endif } BUGS/FEATURES The value returned is the number of argument words. If there is a double in the argument list it increments the argument count by 2. The same bug/feature exists for structure arguments. For my use of the routine this was a desired feature.