From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,f6dda81e7269c676 X-Google-Attributes: gid111c93,public From: "Martin Sinot" Subject: Re: why only 6 params passed in registers? Date: 2000/01/14 Message-ID: <85mtsp$ctb$1@news.telekabel.nl>#1/1 X-Deja-AN: 572519802 References: <85hhsi$lkj$1@nnrp1.deja.com> <85lsaj$o6m$1@mailint03.im.hou.compaq.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Trace: news.telekabel.nl 947845849 13227 212.142.20.102 (14 Jan 2000 10:30:49 GMT) Organization: SPaSE BV X-MSMail-Priority: Normal NNTP-Posting-Date: 14 Jan 2000 10:30:49 GMT Newsgroups: comp.os.linux.alpha Steven Hobbs 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