Parameter Passing via a Stack

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Theo R.

    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.

  • Ian Collins

    #2
    Re: Parameter Passing via a Stack

    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.

    Comment

    • Sharath

      #3
      Re: Parameter Passing via a Stack

      On Apr 2, 1:30 pm, "Theo R." <shortsighted.. .@gmail.comwrot e:
      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?


      -Sharath

      Comment

      • J. J. Farrell

        #4
        Re: Parameter Passing via a Stack

        On Apr 2, 1:30 am, "Theo R." <shortsighted.. .@gmail.comwrot e:
        >
        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.

        Comment

        • santosh

          #5
          Re: Parameter Passing via a Stack

          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.

          Comment

          • Keith Thompson

            #6
            Re: Parameter Passing via a Stack

            "Theo R." <shortsightedsi d@gmail.comwrit es:
            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_Keit h) kst-u@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"

            Comment

            • mark_bluemel@pobox.com

              #7
              Re: Parameter Passing via a Stack

              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?

              Comment

              • Thad Smith

                #8
                Re: Parameter Passing via a Stack

                Sharath wrote:
                On Apr 2, 1:30 pm, "Theo R." <shortsighted.. .@gmail.comwrot e:
                >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

                Comment

                • santosh

                  #9
                  Re: Parameter Passing via a Stack

                  mark_bluemel@po box.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.

                  :-)

                  Comment

                  • Walter Roberson

                    #10
                    Re: Parameter Passing via a Stack

                    In article <1175518890.533 581.141240@q75g 2000hsh.googleg roups.com>,
                    <mark_bluemel@p obox.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

                    Comment

                    • Keith Thompson

                      #11
                      Re: Parameter Passing via a Stack

                      "santosh" <santosh.k83@gm ail.comwrites:
                      mark_bluemel@po box.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_Keit h) kst-u@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"

                      Comment

                      • Gordon Burditt

                        #12
                        Re: Parameter Passing via a Stack

                        >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.


                        Comment

                        • CBFalconer

                          #13
                          Re: Parameter Passing via a Stack

                          mark_bluemel@po box.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

                          Comment

                          • CBFalconer

                            #14
                            Re: Parameter Passing via a Stack

                            "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

                            Comment

                            • Stephen Sprunk

                              #15
                              Re: Parameter Passing via a Stack

                              "Theo R." <shortsightedsi d@gmail.comwrot e in message
                              news:1175502614 .651897.55130@e 65g2000hsc.goog legroups.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

                              Comment

                              Working...