comp.lang.ada
 help / color / mirror / Atom feed
From: Marin David Condic <nobody@noplace.com>
Subject: Re: GNAT parameter passing, C-style?
Date: Fri, 26 Dec 2003 14:20:47 GMT
Date: 2003-12-26T14:20:47+00:00	[thread overview]
Message-ID: <3FEC43B2.5080606@noplace.com> (raw)
In-Reply-To: pan.2003.12.26.10.37.14.290567@n_o_p_o_r_k_a_n_d_h_a_m.abyss2.demon.co.uk

You're talking about the ordering of parameters as they are pushed on 
the stack? I know of no mechanism to control that in the Ada standard 
and I doubt that the standard could possibly specify anything that is 
such a low level implementation detail. What about machines with large 
register sets? Compilers would want to optimize by putting parameters in 
registers and that might mess up the order you think you're getting. 
Different platforms will have different parameter passing mechanisms and 
conventions.

What you refer to as "C-Style" and "Pascal-Style" is probably misleading 
as well. What C compiler on what platform? Likewise for Pascal? AFAIK, 
there is no requirement in C or Pascal to use any particular mechanisms 
for parameter passing (beyond C allowing you to specify that something 
should live in a register.) If you had two different compiler writers 
working on two different platforms, you'd likely get two different 
mechanisms for parameter passing. Should the stack pointer increment or 
decrement as it puts items on the stack? It depends - what's the 
convention on the processor, OS, 
other-compilers-you-wish-to-be-compatible-with combinations? Does the 
machine even have a stack pointer?

If there is any such thing as an Ada mechanism, it would be through the 
pragmas for interfacing to other languages. Indicating that you are 
calling (or being called from) a C program should try to enforce C 
conventions. But there is no one, single "C-Style" anyway, so you'd have 
to know if your Ada compiler lined up with a particular C compiler. With 
Gnat, it is both an Ada and a C compiler, so it is likely to be 
consistent with itself. But Gnat couldn't promise you compatibility with 
someone else's C compiler.

MDC


Luke A. Guest wrote:
> Hi,
> 
> I've just written a program to prove it, but am I correct in saying that
> the GNAT procedure/function calling mechanism is to pass parameters from
> right-to-left (C-style), rather than left-to-right (PASCAL-style)?
> 
> I was also wondering if there is an Ada standard way to changing the
> mechanism? Or this compiler specific?
> 
> Thanks,
> Luke.
> 


-- 
======================================================================
Marin David Condic
I work for: http://www.belcan.com/
My project is: http://www.jsf.mil/NSFrames.htm

Send Replies To: m   o   d   c @ a   m   o   g
                    c   n   i       c   .   r

     "Face it ladies, its not the dress that makes you look fat.
     Its the FAT that makes you look fat."

         --  Al Bundy

======================================================================




  reply	other threads:[~2003-12-26 14:20 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-26 10:37 GNAT parameter passing, C-style? Luke A. Guest
2003-12-26 14:20 ` Marin David Condic [this message]
2003-12-26 14:51   ` Hyman Rosen
2003-12-26 15:07     ` Marin David Condic
2003-12-26 15:39       ` Luke A. Guest
2003-12-26 17:03         ` Hyman Rosen
2003-12-26 17:08           ` Luke A. Guest
2003-12-26 17:27             ` Luke A. Guest
2003-12-26 18:21               ` Frank J. Lhota
2003-12-26 19:06                 ` Frank J. Lhota
2003-12-31 10:23                 ` Keith Thompson
2003-12-31 14:45                   ` Frank J. Lhota
2003-12-31 15:05                     ` Hyman Rosen
2003-12-31 16:30                       ` Frank J. Lhota
2003-12-31 17:24                         ` Hyman Rosen
2003-12-31 19:05                           ` Frank J. Lhota
2003-12-31 19:38                             ` Hyman Rosen
2003-12-31 20:47                               ` Frank J. Lhota
2003-12-31 21:35                                 ` Hyman Rosen
2004-01-01  2:50                                   ` Frank J. Lhota
2004-01-01  5:20                                     ` Luke A. Guest
2004-01-01 16:06                                       ` Hyman Rosen
2004-01-01 16:32                                         ` Frank J. Lhota
2004-01-01 16:43                                           ` Hyman Rosen
2004-01-02  0:24                                             ` Frank J. Lhota
2004-01-02  4:09                                               ` Hyman Rosen
2004-01-02 13:29                                                 ` Frank J. Lhota
2004-01-01  5:17                                   ` Luke A. Guest
2004-01-01  5:09                                 ` Luke A. Guest
2004-01-02  1:17                                   ` tmoran
2004-01-01 17:18                                 ` Jano
2004-01-02  0:25                                   ` Frank J. Lhota
2004-01-07  6:37                         ` Dave Thompson
2004-01-01  3:38                       ` Marin David Condic
2004-01-01  5:28                         ` Luke A. Guest
2004-01-01 14:17                           ` Marin David Condic
2004-01-01 16:20                             ` Jeff C,
2004-01-02 13:47                               ` Marin David Condic
2004-01-05 21:06                     ` Keith Thompson
2004-01-06  3:42                       ` Robert I. Eachus
2004-01-06 20:54                         ` Keith Thompson
2004-01-06 23:45                           ` Robert I. Eachus
2004-01-06 13:46                       ` Frank J. Lhota
2003-12-27 14:22             ` Marin David Condic
2003-12-26 17:10         ` Martin Krischik
2003-12-26 19:04           ` Frank J. Lhota
2003-12-26 18:01   ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox