Wednesday, May 5, 2010

What direction is the stack growing?

You are working on a machine / compiler and you want to determine if the stack is growing towards increasing or decreasing addresses. What strategy would you use?

1 comment:

  1. void func ( const int arg1, const int arg2 )
    {
    if ( &arg1 > &arg2 ) // args pushed right to left in c
    {
    cout << "Stack grows up" << endl;
    }
    else
    {
    cout << "Stack grows down" << endl;
    }
    }

    ReplyDelete