且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

没有返回语句的函数返回值

更新时间:2022-11-11 10:51:37

至少对于 x86,这个函数的返回值应该在 eax 寄存器中.任何存在的东西都会被调用者认为是返回值.

For x86 at least, the return value of this function should be in eax register. Anything that was there will be considered to be the return value by the caller.

因为eax是作为返回寄存器使用的,所以常被调用者作为scratch"寄存器使用,因为不需要保存.这意味着它很有可能被用作任何局部变量.因为它们最后是相等的,所以更有可能在 eax 中留下正确的值.

Because eax is used as return register, it is often used as "scratch" register by callee, because it does not need to be preserved. This means that it's very possible that it will be used as any of local variables. Because both of them are equal at the end, it's more probable that the correct value will be left in eax.