push ebp+---------+
+ 参数M  +
+ --------+
+ return  +
+---------+<-----ebp
+old ebp +
+             +
+++++++ <-----esp
+             +
+             +
+---------+move ebp  esp
+---------+
+ 参数M  +
+ --------+<---ebp+8
+ return  +
+---------+<---ebp+4
+old ebp +
+             +
+++++++ <----ebp = esp
+             +
+             +
+---------+我的理解应该是这样吧,为啥看有的书里面总是下面这样的呢?
+---------+
+ 参数M  +
+ --------+<-----ebp+4是参数M
+ return  +
+---------+<-----ebp指向return address
+old ebp +
+             +
+++++++ 
+             +
+             +
+---------+

解决方案 »

  1.   

    ebp指向的是栈底啊, esp 才是指向栈顶,确定没搞错?(Intel 栈是从高地址向低地址增长的)push ebp+---------+
    + 参数M  +
    + --------+
    + return  +
    +---------+<-----ebp
    +old ebp +
    +             +
    +++++++ <-----esp
    +             +
    +             +
    +---------+move ebp  esp
    +---------+
    + 参数M  +
    + --------+<---ebp+8
    + return  +
    +---------+<---ebp+4
    +old ebp +
    +             +
    +++++++ <----ebp = esp
    +             +
    +             +
    +---------+push  eax
    +---------+
    + 参数M  +
    + --------+<---ebp+8
    + return  +
    +---------+<---ebp+4
    +old ebp +
    +++++++ <----ebp
    +   eax     +
    +++++++<--- esp
    +             +
    +             +
    +             +
    +---------+
      

  2.   

    入栈: 先 - 4,再把数据拷贝到 esp 指向的地址
    出栈:先把数据复制出来,然后 + 4