Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Parameter Passing via a Stack

Reply
Thread Tools

Parameter Passing via a Stack

 
 
Theo R.
Guest
Posts: n/a
 
      04-02-2007
Hi all,

Does the C99 Standard explicitly mention the need for a stack for
passing arguments or Is this platform specific?

As an example, the ARM9 processor recommends Core Registers R0-R3 be
used when passing less than four parameters. However some compilers
for ARM9 do not follow this recommendation and place all parameters on
the stack. Therefore, the question arises if the compilers were
following the C Standard instead.

I remember that order of evaludation is right to left. Is this part of
the standard or is it an implementation detail?

Thanks,
Theo.

 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      04-02-2007
Theo R. wrote:
> Hi all,
>
> Does the C99 Standard explicitly mention the need for a stack for
> passing arguments or Is this platform specific?
>

No, it is an implementation detail.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
Sharath
Guest
Posts: n/a
 
      04-02-2007
On Apr 2, 1:30 pm, "Theo R." <(E-Mail Removed)> wrote:
> Hi all,
>
> Does the C99 Standard explicitly mention the need for a stack for
> passing arguments or Is this platform specific?


No.

> I remember that order of evaludation is right to left. Is this part of
> the standard or is it an implementation detail?


Wrong. Order of evaluation is unspecified.

Why don't you get yourself a copy of standard and see yourself?
http://www.open-std.org/JTC1/SC22/WG...docs/n1124.pdf

-Sharath

 
Reply With Quote
 
J. J. Farrell
Guest
Posts: n/a
 
      04-02-2007
On Apr 2, 1:30 am, "Theo R." <(E-Mail Removed)> wrote:
>
> Does the C99 Standard explicitly mention the need for a stack for
> passing arguments or Is this platform specific?


It's an implementation detail - C doesn't need a stack at all.

> ...


> I remember that order of evaludation is right to left. Is this part of
> the standard or is it an implementation detail?


It's an implementation detail, and the implementation is not required
to document it.

 
Reply With Quote
 
santosh
Guest
Posts: n/a
 
      04-02-2007
Theo R. wrote:
> Hi all,
>
> Does the C99 Standard explicitly mention the need for a stack for
> passing arguments or Is this platform specific?


No.

> As an example, the ARM9 processor recommends Core Registers R0-R3 be
> used when passing less than four parameters. However some compilers
> for ARM9 do not follow this recommendation and place all parameters on
> the stack. Therefore, the question arises if the compilers were
> following the C Standard instead.


The Standard says nothing about how function parameters are managed,
just that they're made available to the function itself.

 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      04-02-2007
"Theo R." <(E-Mail Removed)> writes:
> Does the C99 Standard explicitly mention the need for a stack for
> passing arguments or Is this platform specific?


The word "stack" appears nowhere in the C99 standard (nor does the
word "heap"). Argument passing mechanisms are
implementation-specific.

[...]

> I remember that order of evaludation is right to left. Is this part of
> the standard or is it an implementation detail?


That's also implementation-specific.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
mark_bluemel@pobox.com
Guest
Posts: n/a
 
      04-02-2007
My glasses must be playing up - I initially read the subject line as
"Parameter Passing via a Stick". Anyone for an April 1st RFC? Would it
be possible to produce a compliant implementation using a Stick for
passing parameters?

 
Reply With Quote
 
Thad Smith
Guest
Posts: n/a
 
      04-02-2007
Sharath wrote:
> On Apr 2, 1:30 pm, "Theo R." <(E-Mail Removed)> wrote:


>> I remember that order of evaludation is right to left. Is this part of
>> the standard or is it an implementation detail?

>
> Wrong. Order of evaluation is unspecified.


It is an implementation detail.

The question makes it obvious that right-to-left evaluation is for a
particular implementation and asks whether such behavior is standard.
The answer "wrong" is wrong for the question asked.

--
Thad
 
Reply With Quote
 
santosh
Guest
Posts: n/a
 
      04-02-2007
(E-Mail Removed) wrote:
> My glasses must be playing up - I initially read the subject line as
> "Parameter Passing via a Stick". Anyone for an April 1st RFC? Would it
> be possible to produce a compliant implementation using a Stick for
> passing parameters?


Yes. Those are just implementation details. Currently the most popular
parameter passing mechanism for the DS9k are wormholes, and carrier
pigeons for variable length args.



 
Reply With Quote
 
Walter Roberson
Guest
Posts: n/a
 
      04-02-2007
In article <(E-Mail Removed) .com>,
<(E-Mail Removed)> wrote:
>My glasses must be playing up - I initially read the subject line as
>"Parameter Passing via a Stick".


<OT>
In networking, there is a not-uncommon configuration called
"Router on a Stick", which refers to using a router to route
between different subnets on the same physical segment, with
the packets going into the router and back out by the same
physical interface. Used when you have multiple IP ranges on the
same LAN. As contrasted to routing between different
physical interfaces, which is traditionally used when there
is an "inside" and an "outside" such as routing between a LAN
and the Internet.
</OT>
--
There are some ideas so wrong that only a very intelligent person
could believe in them. -- George Orwell
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does std::stack::pop() not throw an exception if the stack is empty? Debajit Adhikary C++ 36 02-10-2011 08:54 PM
Passing parameter to function not expecting parameter Mister B C Programming 8 08-26-2010 08:01 AM
C/C++ compilers have one stack for local variables and return addresses and then another stack for array allocations on the stack. Casey Hawthorne C Programming 3 11-01-2009 08:23 PM
stack frame size on linux/solaris of a running application stack Surinder Singh C Programming 1 12-20-2007 01:16 PM
"stack level too deep"... because Threads keep their "starting" stack Sam Roberts Ruby 1 02-11-2005 04:25 AM



Advertisments