number of arguments function for 4.1bsd VAX cc(1) -- TYPO FIX

Dave Long long at oliveb.UUCP
Sat Feb 23 10:09:01 AEST 1985


[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.



More information about the Comp.lang.c mailing list