Variable argument lists.

John F. Haugh II jfh at rpp386.UUCP
Fri May 13 14:39:06 AEST 1988


In article <11435 at mimsy.UUCP> chris at mimsy.UUCP writes:
>In article <14139 at brl-adm.ARPA> bates%falcon.dnet%fermat at bru.mayo.edu
>>In VAX C [by which I presume he means some version of VMS C] there
>>is a macro called va_count.
>
>I would bet that it does not work.  Try:

[ example deleted ]

>Chances are the program will print either 5 or 4.  Neither is
>correct.
>-- 
>In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)

this function can be implemented if the C compiler uses the CALLS
instruction.  CALLS is of the form

	CALLS	#<number-of-arguments>,<where-to-go>

the number of arguments is stacked by the call instruction and can be
found (if i remember - it can be found however) by referencing the
value located at (AP).

this mechanism also works for the CALLG instruction which expects
an argument list which has been setup to include the count.  (FORTRAN
uses CALLG since the argument list can be statically allocated)  when
CALLG is executed, AP is loaded with the address provided as the
first argument to the instruction.

- john.
-- 
John F. Haugh II                 | "You see, I want a lot. Perhaps I want every
River Parishes Programming       | -thing.  The darkness that comes with every
UUCP:   ihnp4!killer!rpp386!jfh  | infinite fall and the shivering blaze of
DOMAIN: jfh at rpp386               | every step up ..." -- Rainer Maria Rilke



More information about the Comp.lang.c mailing list