gpt4 book ai didi

在 gcc 内联汇编中调用函数

转载 作者:IT王子 更新时间:2023-10-29 01:14:36 25 4
gpt4 key购买 nike

比如说,我想在 gcc 的内联汇编中调用具有以下签名的函数。我该怎么做?

int some_function( void * arg );

最佳答案

通常你会想做类似的事情

void *x;
asm(".. code that writes to register %0" : "=r"(x) : ...
int r = some_function(x);
asm(".. code that uses the result..." : ... : "r"(r), ...

也就是说,您根本不想在内联汇编中进行函数调用。这样您就不必担心调用约定或堆栈框架管理的细节。

关于在 gcc 内联汇编中调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7984209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com