Return value of a C function to ASM

后端 未结 3 1970
盖世英雄少女心
盖世英雄少女心 2021-02-14 02:51

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:

3条回答
  •  深忆病人
    2021-02-14 03:19

    Although the answers are sufficient to answer the OP's question, here's an extract covering most cases from DJPP's manpage for completeness:

    Return Value

    • Integers (of any size up to 32 bits) and pointers are returned in the %eax register.
    • Floating point values are returned in the 387 top-of-stack register, st(0).
    • Return values of type long long int are returned in %edx:%eax (the most significant word in %edx and the least significant in %eax).
    • Returning a structure is complicated and rarely useful; try to avoid it. (Note that this is different from returning a pointer to a structure.)

    If your function returns void (e.g. no value), the contents of these registers are not used.

提交回复
热议问题