4

I'm wondering if it makes sense to push the return value of a function in its the stack-frame.

I know return values are mostly stored in registers (eax for gcc), but is it for performance only?

Thanks!

4

1 回答 1

9

这是有道理的,但必须手动插入(而不是简单的推送)。它的“空间”应该由调用者“分配”(它必须在调用函数之前减少 sp)因为当你从函数返回时 - 返回地址必须在堆栈的顶部,所以返回值应该是在退货地址下方。[与在堆栈上传递参数的原理相同]

于 2011-08-08T10:14:49.967 回答