473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Parameter Passing via a Stack

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.

Apr 2 '07 #1
16 3344
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.
Apr 2 '07 #2
On Apr 2, 1:30 pm, "Theo R." <shortsighted...@gmail.comwrote:
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

Apr 2 '07 #3
On Apr 2, 1:30 am, "Theo R." <shortsighted...@gmail.comwrote:
>
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.

Apr 2 '07 #4
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.

Apr 2 '07 #5
"Theo R." <sh*************@gmail.comwrites:
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) ks***@mib.org <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"
Apr 2 '07 #6
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?

Apr 2 '07 #7
Sharath wrote:
On Apr 2, 1:30 pm, "Theo R." <shortsighted...@gmail.comwrote:
>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
Apr 2 '07 #8
ma**********@pobox.com 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.

:-)

Apr 2 '07 #9
In article <11**********************@q75g2000hsh.googlegroups .com>,
<ma**********@pobox.comwrote:
>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
Apr 2 '07 #10
"santosh" <sa*********@gmail.comwrites:
ma**********@pobox.com 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.

:-)
Are those "wormholes" in the sense of discontinuities in the
space-time continuum, or "wormholes" in the sense of holes dug by
worms? Or is it a compile-time option?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <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"
Apr 2 '07 #11
>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 (and I don't mean that as an April 1st joke). You spear the
arguments in the correct order on the stick, and then pass the stick
(with the arguments attached) to the function.

But I think "Parameter Passing via Federal Express" is more
interesting. For a related method, see RFC2549.
Apr 3 '07 #12
ma**********@pobox.com 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?
Sure. For example, come up with conventions for the spacing and
sizes of the whittled notches. Hire small boys with penknives.
The system would probably be fairly slow, but then there are no C
standards for speed.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Apr 3 '07 #13
"Theo R." wrote:
>
Does the C99 Standard explicitly mention the need for a stack for
passing arguments or Is this platform specific?
bash-2.04$ grep stack /stds/n869.txt
bash-2.04$
--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Apr 3 '07 #14
"Theo R." <sh*************@gmail.comwrote in message
news:11*********************@e65g2000hsc.googlegro ups.com...
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.
The C Standard says nothing about this, nor does it require that an
implementation have "registers" or a "stack" (or a "heap") at all.

Each platform (OS/CPU combination) does tend to have an Application Binary
Interface (ABI) standard, and compilers/linkers are expected to conform to
that. However, the ABI is not part of the C Standard, so an implementation
can disregard the accepted ABI and still be conforming according to
ISO/ANSI.

(Some ABIs, e.g. x86, even define multiple calling conventions, but they'll
specify one as the default. It's up to the programmer to make sure the
right compiler extensions or options are used if a non-default calling
convention is needed.)

S

--
Stephen Sprunk "Those people who think they know everything
CCIE #3723 are a great annoyance to those of us who do."
K5SSS --Isaac Asimov
--
Posted via a free Usenet account from http://www.teranews.com

Apr 3 '07 #15
CBFalconer wrote, On 03/04/07 01:59:
"Theo R." wrote:
>Does the C99 Standard explicitly mention the need for a stack for
passing arguments or Is this platform specific?

bash-2.04$ grep stack /stds/n869.txt
bash-2.04$
Although the result is correct in this case, you really should use a
case insensitive search to demonstrate it. Or just answer the question
since the OP might not know about grep.
--
Flash Gordon
Apr 3 '07 #16
CBFalconer wrote:
"Theo R." wrote:
>>
Does the C99 Standard explicitly mention the need for a stack for
passing arguments or Is this platform specific?

bash-2.04$ grep stack /stds/n869.txt
bash-2.04$
Perhaps all occurrences of Stack were spelt with at least one
capital letter?

--
The second Jena user conference! http://hpl.hp.com/conferences/juc2007/
"If there is a problem, you must confess it, Mr Chaplin"/The Beiderbeck Affair/

Hewlett-Packard Limited registered office: Cain Road, Bracknell,
registered no: 690597 England Berks RG12 1HN

Apr 3 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Herring | last post by:
Hi there: Well, let me start off by saying that I am a Visual Studio drag and drop weenie, not a real programmer. So I tend to get confused when things do not look like the instructions said they...
3
by: Douwe | last post by:
I try to build my own version of printf which just passes all arguments to the original printf. As long as I keep it with the single argument version everything is fine. But their is also a version...
19
by: Yoon Soo | last post by:
Hi, there while mixing assembler and c code I got the following question: struct bar { int bar_val1; int bar_val2; (...) }
14
by: Pollux | last post by:
I'm having a problem with something I thought was quite simple. I have a function in a C DLL. Let's call it SomeFunction. This is the prototype for SomeFunction: void SomeFunction(char *...
13
by: Maxim | last post by:
Hi! A have a string variable (which is a reference type). Now I define my Method like that: void MakeFullName(string sNamePrivate) { sNamePrivate+="Gates" }
0
by: Diane Truyens | last post by:
I have an objectdatasource on a dataset. From a webform (textbox) I want to pass a parameter to this dataset which can be null. If so I want all the rows of that dataset to be retrieved in a...
4
by: Mahmoud Al-Qudsi | last post by:
Hi all, I'm working on a C# project, and at some point I'm needing to pass the same stack to multiple functions. I found out the hard way that when I poss a stack by value it doesn't actually...
14
by: Mathijs | last post by:
Hi group, I have a class (TheClass) with static methods from an external DDL. private void Test(ref byte param) { byte a = 0, b = 0; param = 1; TheClass.CallToDLLFunction(ref a, ref b);...
8
by: asit | last post by:
How do I pass parameters to created thread..here is the code(but it can't pass data..it uses global variable) #include <windows.h> #include <stdio.h> DWORD Sum; DWORD WINAPI...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.