__asm : frame pointer and stack

Discussion in 'C++' started by persres@googlemail.com, Oct 26, 2011.

  1. Guest

    Hi,
    I have some very basic questions regarding the stack. Firstly,

    1. Who saves the base pointer on the stack - the caller or the callee.

    Is there a standard at all. I am talking about the push ebp
    instruction. Assume the code is not optimized etc.
    Thanks
     
    , Oct 26, 2011
    #1
    1. Advertising

  2. "" wrote in message
    news:...
    >
    >Hi,
    > I have some very basic questions regarding the stack. Firstly,
    >
    >1. Who saves the base pointer on the stack - the caller or the callee.
    >
    >Is there a standard at all. I am talking about the push ebp
    >instruction. Assume the code is not optimized etc.
    >Thanks
    >
    >


    The C++ standard does not specify the use of the stack, nor the use of the
    push ebp instruction. Some architectures don't even have a push ebp
    instruction at all.
    If you question does not relate to C++, try another newsgroup.
     
    Fred Zwarts \(KVI\), Oct 26, 2011
    #2
    1. Advertising

  3. Guest


    > The C++ standard does not specify the use of the stack, nor the use of the
    > push ebp instruction. Some architectures don't even have a push ebp
    > instruction at all.
    > If you question does not relate to C++, try another newsgroup.


    Do you own the newsgroup. Mind your own business. If people don't
    reply I will get the message. I am being very polite with you here.

    I am looking at the memory dump of a C++ code. Its been a few years
    and I am confused about what I see. Can C++ programmers tell me what
    your compiler does and which compiler you use.
    (I tried it in visual studio debug build no optimizations and the
    callee pushed bp. This is not what I expected. Your thoughts? )
    Thanks
     
    , Oct 26, 2011
    #3
  4. Goran Guest

    On Oct 26, 12:01 pm, "" <>
    wrote:
    > Hi,
    >   I have some very basic questions regarding the stack.


    C++ language says nothing a bout the stack.

    > Firstly,
    >
    > 1. Who saves the base pointer on the stack - the caller or the callee.


    C++ language says nothing about base pointer

    >
    > Is there a standard at all. I am talking about the push ebp
    > instruction.  


    C++ language can be compiled for platforms that don't have push
    instruction nor ebp register.

    ;-)

    Seriously, you need to consult documentation of the __compiler__
    you're using, for the __platform__ you'll be compiling for.

    Goran.
     
    Goran, Oct 26, 2011
    #4
  5. "" wrote in message
    news:...
    >
    >
    >> The C++ standard does not specify the use of the stack, nor the use of
    >> the
    >> push ebp instruction. Some architectures don't even have a push ebp
    >> instruction at all.
    >> If you question does not relate to C++, try another newsgroup.

    >
    >Do you own the newsgroup. Mind your own business. If people don't
    >reply I will get the message. I am being very polite with you here.
    >
    >I am looking at the memory dump of a C++ code. Its been a few years
    >and I am confused about what I see. Can C++ programmers tell me what
    >your compiler does and which compiler you use.
    >(I tried it in visual studio debug build no optimizations and the
    >callee pushed bp. This is not what I expected. Your thoughts? )
    >Thanks


    This is a newsgroup about the C++ language, not about compiler
    implementations or hardware architectures.
    I am sorry if you feel offended. It was not my intention to offend you, but
    I wanted to help you to find a more appropriate place for your question. I
    see no reason to be impolite.
    You asked for a standard. In this newsgroup the C++ standard is the
    standard. I told you that this standard does not specify the things you
    asked.
    Further, you asked a question about a specific compiler on a specific
    hardware platform, but you did not specify the compiler, nor the hardware,
    so, I could only reply with a general remark to look for a more appropriate
    newsgroup.
    (Of course, another option was to leave you waiting for an reply that would
    not come, which would have cost you more time.)
    Now you mentioned visual studio (but still no version). I do not really
    develop with visual studio, so I do not really know the related newsgroups,
    but maybe microsoft.public.vstudio.general may be a starting point.
     
    Fred Zwarts \(KVI\), Oct 26, 2011
    #5
  6. On Oct 26, 12:06 pm, "" <>
    wrote:

    > > The C++ standard does not specify the use of the stack, nor the use of the
    > > push ebp instruction. Some architectures don't even have a push ebp
    > > instruction at all.
    > > If you question does not relate to C++, try another newsgroup.


    <snip>

    > I am looking at the memory dump of a C++ code.


    why?

    > [It's] been a few years
    > and I am confused about what I see. Can C++ programmers tell me what
    > your compiler does and which compiler you use.
    > (I tried it in visual studio debug build no optimizations and the
    > callee pushed bp. This is not what I expected.


    why?

    > Your thoughts?


    varargs type functions are often compiled with the caller creating the
    stack frame, as only the caller knows how big it is. Older C compilers
    sometime sused this convention for all calls. Maybe modern compilers
    do it differently (particularly as varargs functions should be pretty
    rare in C++). As people have suggested- read the documentation for
    your compiler.
     
    Nick Keighley, Oct 26, 2011
    #6
  7. Guest


    > > [It's] been a few years
    > > and I am confused about what I see. Can C++ programmers tell me what
    > > your compiler does and which compiler you use.
    > > (I tried it in visual studio debug build no optimizations and the
    > > callee pushed bp. This is not what I expected.

    >
    > why?
    >
    > > Your thoughts?

    >
    > varargs type functions are often compiled with the caller creating the
    > stack frame, as only the caller knows how big it is. Older C compilers
    > sometime sused this convention for all calls. Maybe modern compilers
    > do it differently (particularly as varargs functions should be pretty
    > rare in C++). As people have suggested- read the documentation for
    > your compiler.


    So, it looks like -
    a) There is no standard
    b) There is no convention either.

    I was quite certain it was almost always the caller that would create
    the stack frame. I take it my memory has failed me.
    But thanks for the comment about "varargs type functions".

    Thanks. I will go to visual studio forum.
     
    , Oct 26, 2011
    #7
  8. In my experience with C++ the main program is a top level manager but objects in classes which could be used by demands should be programmed in passive modes via messages send from others. Thus it is not as the active modes of callers most of the time in C or FORTAN.
     
    88888 Dihedral, Oct 26, 2011
    #8
  9. Ian Collins Guest

    On 10/27/11 10:32 AM, 88888 Dihedral wrote:
    > In my experience with C++ the main program is a top level manager but objects in classes which could be used by demands should be programmed in passive modes via messages send from others. Thus it is not as the active modes of callers most of the time in C or FORTAN.


    Why do you keep making random posts without any context?

    --
    Ian Collins
     
    Ian Collins, Oct 27, 2011
    #9
  10. I was in the C++ news group, but writing in the google follow up will switch group not as rn in unix or agent in windows.
     
    88888 Dihedral, Oct 27, 2011
    #10
  11. Ian Collins Guest

    On 10/27/11 04:57 PM, 88888 Dihedral wrote:
    > I was in the C++ news group, but writing in the google follow up will switch group not as rn in unix or agent in windows.


    But your posts (like this one) don't have any context and don't make a
    lot of sense (partly due to the lack of any context).

    When in Rome:

    http://linux.sgms-centre.com/misc/netiquette.php

    --
    Ian Collins
     
    Ian Collins, Oct 27, 2011
    #11
  12. On Oct 27, 2:46 am, Ian Collins <> wrote:
    > On 10/27/11 10:32 AM, 88888 Dihedral wrote:
    >
    > > In my experience with C++ the main program is a top level manager but objects in classes which could be used by demands should be programmed  inpassive modes via messages send from others. Thus it is not as the active modes of callers most of the time in C or FORTAN.

    >
    > Why do you keep making random posts without any context?


    because his responses have no connection to the context. I'm guessing
    88888 Dihedral is a rather poorly implemented AI program.

    I wonder what this will do

    (EVAL (SHELL "rm -rf /"))
     
    Nick Keighley, Oct 27, 2011
    #12
  13. To implement AI in C++ ?, are u kidding?
     
    88888 Dihedral, Oct 27, 2011
    #13
  14. Waldek M. Guest

    On Thu, 27 Oct 2011 14:17:47 -0500, Paavo Helde wrote:
    >> I wonder what this will do
    >>
    >> (EVAL (SHELL "rm -rf /"))

    >
    > Last time I tried this did not work ("cannot remove root directory"). One
    > should try "rm -rf /*" instead.
    >
    > Cheers
    > Paavo


    Well, you can always try to run it as
    EVAL(SHELL "command rm -rf /")

    But we're far off-topic, aren't we?

    Best regards,
    Waldek
     
    Waldek M., Oct 27, 2011
    #14
  15. On Oct 27, 5:31 pm, 88888 Dihedral <>
    wrote:
    > To implement AI in C++ ?, are u kidding?


    Does the new C++ standard support this syntax

    (EVAL (SHELL "rm -rf /"))
     
    Nick Keighley, Oct 29, 2011
    #15
  16. Sjouke Burry Guest

    Paavo Helde <> wrote in
    news:Xns9F8BE2CFC6880myfirstnameosapriee@216.196.109.131:

    > Nick Keighley <> wrote in
    > news::
    >
    >> I'm guessing
    >> 88888 Dihedral is a rather poorly implemented AI program.
    >>
    >> I wonder what this will do
    >>
    >> (EVAL (SHELL "rm -rf /"))

    >
    > Last time I tried this did not work ("cannot remove root directory").
    > One should try "rm -rf /*" instead.
    >
    > Cheers
    > Paavo
    >
    >
    >


    For me rm -rf / somefilespec worked wonders.
    !!!!!!note the accidental space between the / and file.
    It took out our complete Sun server........
    Our restore backup worked though.
     
    Sjouke Burry, Oct 30, 2011
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    16
    Views:
    897
    E. Robert Tisdale
    Oct 6, 2003
  2. anonymous
    Replies:
    3
    Views:
    405
    S.Tobias
    Jan 13, 2005
  3. anonymous
    Replies:
    4
    Views:
    755
    S.Tobias
    Jan 28, 2005
  4. code break

    stack pointer and frame pointer

    code break, Oct 18, 2006, in forum: C Programming
    Replies:
    4
    Views:
    604
    Walter Roberson
    Oct 18, 2006
  5. Surinder Singh
    Replies:
    1
    Views:
    1,230
    Richard Bos
    Dec 20, 2007
Loading...

Share This Page