From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: ** X-Spam-Status: No, score=2.2 required=5.0 tests=BAYES_00,FROM_WORDY, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ac02560f0af03a21 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-01-01 08:32:48 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!hermes.visi.com!199.184.165.244.MISMATCH!rcn!feed3.news.rcn.net!not-for-mail Reply-To: "Frank J. Lhota" From: "Frank J. Lhota" Newsgroups: comp.lang.ada References: <1072450300.440355@master.nyc.kbcfp.com> <3FEC4E89.2070804@noplace.com> <1072458199.346049@master.nyc.kbcfp.com> <3fec7c21$0$4764$61fed72c@news.rcn.com> <4iBIb.8173$qS3.498@nwrdny03.gnilink.net> <1072883131.278899@master.nyc.kbcfp.com> <1072891494.595791@master.nyc.kbcfp.com> <1072899508.453543@master.nyc.kbcfp.com> <1072906542.723974@master.nyc.kbcfp.com> <3ff38b16$0$4759$61fed72c@news.rcn.com> Subject: Re: GNAT parameter passing, C-style? Date: Thu, 1 Jan 2004 11:32:45 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: <3ff44baf$0$4754$61fed72c@news.rcn.com> NNTP-Posting-Host: 209.6.176.101 X-Trace: 1072974767 reader3.news.rcn.net 4754 209.6.176.101:3958 X-Complaints-To: abuse@rcn.com Xref: archiver1.google.com comp.lang.ada:4015 Date: 2004-01-01T11:32:45-05:00 List-Id: "Hyman Rosen" wrote in message news:bAXIb.28439$tY5.3073@nwrdny01.gnilink.net... > Even if parameters are passed on the stack, there is no need > to process the arguments from right to left. You can just > subtract the appropriate amount from the stack pointer and > then fill in that space by processing the arguments from left > to right. The problem, again, is with variable argument lists. For functions with variable argument lists, such as like printf and fprintf , the "appropriate amount" will vary from call to call. In any such function, there are one or more fixed parameters, from which one can the number and type of the remaining parameters. Before we can determine the size of the argument block, we must be able to retrieve the first few arguments. Given the "Last in, First out" nature of a stack, the easiest way to do that is to push the parameters on the stack in reverse order. With printf, for example, the format string is the last parameter pushed on the stack. Within printf, the format string is at the top of the stack, and it can be used to determine the rest of the parameters.