passing variable numbers of arguments

Stephen J. Friedl friedl at vsi.COM
Wed Jan 11 11:54:04 AEST 1989


In article <9321 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn ) writes:
> 
> The reason that
> the va_ stuff must be used for portable access to arguments is that
> many architectures do not have a simple, clean model for argument
> alignment (which might be different from that indicated by sizeof),
> and some pass some of the arguments different from others.

Doug is being polite here -- there are some *very* crazy
arg-passing schemes out there.

The Zilog Z8000 machine I used in school had an "efficient"
arg passing mechanism that passed the first few args in
registers.  There were six or so 16-bit registers allocated for
this, and 32-bit quantities passed in register pairs R0+R1 = RR0,
R2+R3=RR2, etc.  There were all kinds of rules for alignment
restrictions on this, *PLUS* the machine had a segmented and a
non-segmented mode which meant that pointers could be two
different lengths.  If they had varargs (it was Sys III), it must
have been hell to put together.  I do know that their _doprnt()
had *five* args to accomodate this.

I remember a time several years ago in school that I naively
claimed that taking the address of an arg and (*argp++) up the
stack was portable because "everybody passes args this way".  The
amazing follies of youth :-).

     Steve

-- 
Stephen J. Friedl        3B2-kind-of-guy            friedl at vsi.com
V-Systems, Inc.        I speak for me only      attmail!vsi!friedl
Santa Ana, CA  USA       +1 714 545 6442    {backbones}!vsi!friedl
-------Nancy Reagan on Usenix in San Diego: "Just say *go*"-------



More information about the Comp.lang.c mailing list