Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site oliveb.UUCP Path: utzoo!utcs!lsuc!pesnta!hplabs!oliveb!long From: long@oliveb.UUCP (Dave Long) Newsgroups: net.lang.c Subject: Re: number of arguments function for 4.1bsd VAX cc(1) -- TYPO FIX Message-ID: <271@oliveb.UUCP> Date: Fri, 22-Feb-85 19:09:01 EST Article-I.D.: oliveb.271 Posted: Fri Feb 22 19:09:01 1985 Date-Received: Sat, 23-Feb-85 11:44:08 EST References: Reply-To: long@oliveb.UUCP (Dave Long) Organization: D&L U., Thaumaturgy Lines: 27 Keywords: coding tricks, asm keyword Summary: [Sorry if you're seeing this twice. There was a typo so I sent out a cancel, but knowing netnews, the old article will arrive about 1.73 weeks before the cancel] The following function will return the number of arguments of the function that called it. It works with cc(1) for 4.1bsd running on a Vax. I can't think of any uses for it, but it certainly beats passing an argument telling how many ar- guments the function will receive. int numargs() { asm(" clrl r1"); asm(" subb3 8(fp),$92,r1"); asm(" ashl $-2,r1,r0"); /* changed $2 to $-2 */ } If you would like to know why this works, or if it doesn't work on your 4.1bsd VAX system after having been compiled by cc(1), or you don't think this was an appropriate posting, mail to me. -- gnoL evaD {msoft,allegra,gsgvax,fortune,hplabs,idi,ios, nwuxd,ihnp4,tolrnt,tty3b,vlsvax1,zehntel}!oliveb!long I'd rather be in a universe whose Creator had a bit more mechanical aptitude and a little less imagination.