C函数到ASM的返回值 [英] Return value of a C function to ASM

查看:1154
本文介绍了C函数到ASM的返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从ASM中调用一个函数。我知道如何称呼它,但我无法找到如何得到这个函数的返回值。示例如下:

I'm trying to call a function from within ASM. I know how to call it, but i'm having trouble finding how to get the return value of this function. An example follows:

C code:

int dummy() {  
    return 5;  
}  

(N)ASM code:

dummyFunction:
    call dummy
    ;grab return into eax
    inc eax ; eax should be 6 now
    ret  

任何想法?

推荐答案

返回值是在 EAX 。如果你已经从所谓的ASM C函数,你可以阅读 EAX 的返回值。如果你想从asm函数为C返回,存储在预定的返回值 EAX

The return value is in eax. If you've called a C function from asm, you can read the return value from eax. If you're trying to return from an asm function to C, store the intended return value in eax.

事情变得更加复杂一点,返回浮点值,长长值,或结构,所以问如果你需要和别人(也许我)会帮助你。

Things get a little bit more complicated for returning floating point values, long long values, or structures, so ask if you need that and someone (maybe me) will help you.

这篇关于C函数到ASM的返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆