From: "Martin Sinot" <martin@spase.nl>
Subject: Re: why only 6 params passed in registers?
Date: 2000/01/14 [thread overview]
Message-ID: <85mtsp$ctb$1@news.telekabel.nl> (raw)
In-Reply-To: 85lsaj$o6m$1@mailint03.im.hou.compaq.com
Steven Hobbs <hobbs@steven.zko.dec.com> wrote in message
news:85lsaj$o6m$1@mailint03.im.hou.compaq.com...
> Consider the example of a varargs function, like printf in C. On
> entry to printf, the routine does not know whether it has just 1
> argument or 18 arguments or even more until it has decoded the format
> string argument. It also does not not know whether the arguments are
> in the floating registers or in the integer registers. With the
> current calling standard printf needs to save 5 integer registers and
> and 5 floating registers until it has decoded the format string. If
> the calling standard passed 18 arguments in registers then printf
> would need to save 17 integer registers and 17 floating registers.
> This is a lot of overhead, given that most varargs routines (including
> printf) rarely use these many arguments.
If I remember correctly, only arguments which are actually
specified can be passed in registers. So in the printf case, there
is only one parameter passed in a register, the format string.
The variable arguments are always passed on the stack. Otherwise
you would need to keep track inside such a function where the
variable parameters actually are. That requires a lot of bookkeeping
and introduces a huge architecture dependency. As it is, printf
only needs to save the nonvolatile registers it actually uses
(the six parameter registers, int or float, need not be saved,
unless somebody requires a pointer to one of these parameters).
--
Martin Sinot
Nijmegen, Netherlands
martin@spase.nl
next prev parent reply other threads:[~2000-01-14 5:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-01-12 5:00 why only 6 params passed in registers? david_morse
2000-01-12 5:00 ` Alex Rhomberg
2000-01-12 5:00 ` Martin Sinot
2000-01-12 5:00 ` Serguei Patchkovskii
2000-01-14 5:00 ` Chris
2000-01-14 5:00 ` Serguei Patchkovskii
2000-01-14 5:00 ` Chris
2000-01-15 5:00 ` Greg Lindahl
2000-01-15 5:00 ` Chris
2000-01-15 5:00 ` Serguei Patchkovskii
2000-01-16 5:00 ` Chris
2000-01-16 5:00 ` Serguei Patchkovskii
2000-01-14 5:00 ` Steven Hobbs
2000-01-14 5:00 ` Martin Sinot [this message]
2000-01-14 5:00 ` Steven Hobbs
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox