Drawing a stack frame for x86 assembly

后端 未结 4 1644
旧巷少年郎
旧巷少年郎 2020-12-23 11:01

So, I am kind of confused about drawing a stack frame for my assembly code. I have a feeling I started out wrong.

Here is what I got so far, but as you can see I am

4条回答
  •  攒了一身酷
    2020-12-23 11:33

    You are right with your diagram. The compiler uses some optimizing tricks: the first call is "quite normal", indeed the "f" parameter is placed on top of the stack. The second call is postponed after the local context cleanup (instruction "leave"), and the "h" function's parameter ir "recycled" to contain "2". Than the second "call" to "f" becomes a simple "jmp", since it's the very last line in the calling function "h" (the context of "h" has been already thrown away by "leave").

    Bye!

提交回复
热议问题