home .. forth .. misc mail list archive ..

Re: MISC-d Digest V96 #15


Jaap van Ganswijk <ganswijk@xs4all.nl> said:
>I'm still wondering how current RISC processors that
>have only a limited number of registers in which they try
>to convey the function arguments, do this when there
>is an unknown number of arguments, like in printf().

The standard technique is to pass the first "k" number of arguments, where
k is some small positive integer chosen by the compiler writer, in
registers and push the rest directly onto the stack.  In the case of
brain-dead languages like C, the programmer is responsible for determining
how many arguments were in fact passed and using only that many.  In other
languages, the compiler writer will have defined a calling protocol that
will (USUALLY) tell the called routine how many arguments were passed.