gpt4 book ai didi

c - X86 32b 汇编 - 使用 atoll

转载 作者:太空宇宙 更新时间:2023-11-04 02:48:59 26 4
gpt4 key购买 nike

在 Ubuntu 12.04 下,并且可能使用 x86 32 位汇编和 C 库,我需要使用一个数字 n

 2^31 - 1 < n <= 2^63 -1          

在我的系统上,C 整数是 32 位的;和 long longs 64 位。我知道在获得号码后如何继续,但我仍然坚持要准备好号码。

我的计划方法如下:

 - store n as a string in the .data segment    

- use atoll (pushl $n_Str, call atoll)

- retrieve the converted value, and store it in two consecutive int-sized storage locations (taking note of likely little-endian storage)

由于通过 %eax 的通常 32 位返回值约定无法应用(或者只能通过指针,我检查过似乎不是这种情况(%eax 指向之后不可访问的内存)),我假设该值可能在 (%eax, %ebx) 中。假设是这种情况,我检查了所有高/低排列,但似乎并非如此(如果是,我搞砸了,请指出正确的方法)。环礁的 man(和 man 3)页面没有帮助。

如何检索转换后的整数?如果这种方法是不可能的(strtoll 有同样的问题),有什么替代方案的建议吗?

最佳答案

这似乎取决于调用约定和编译器。 __stdcall 函数在 EAX:EDX 寄存器中成对返回 64 位整数。 __cdecl 函数返回指向堆栈的指针,指向 GCC 上的整数。 __cdecl Visual C++ 函数在 EAX:EDX 中返回一对。

这是来源:http://en.wikibooks.org/wiki/X86_Assembly/High-Level_Languages

关于c - X86 32b 汇编 - 使用 atoll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24126671/

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