Reputation: 2139
Under Ubuntu 12.04., and using x86 32 bit assembly possibly with C libraries, I need to use a number n which is
2^31 - 1 < n <= 2^63 -1
On my system, C ints are 32 bit; and long longs 64 bit. I know how to proceed after having the number, but am stuck on getting the number ready.
My planned approach was as follows:
- 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)
As the usual 32 bit return value convention through %eax cannot apply (or only possibly through a pointer, which I have checked seems to not be the case (%eax points to inaccessible memory after)), I assumed the value might be in (%eax, %ebx). I checked all permutations of high/low assuming this were the case, but it doesn't seem to be (if it is, and I messed up, kindly point out the proper way). The man (and man 3) page for atoll doesn't help.
How do I retrieve the converted integer? If this approach is impossible (strtoll has the same issue), any suggestions for alternatives?
Upvotes: 1
Views: 1440
Reputation: 47640
It seems to depend on calling convention and compiler. __stdcall
functions return 64-bit integers in pairs in EAX:EDX
registers. __cdecl
functions return a pointer to stack to the integer on GCC. __cdecl
functions on Visual C++
return a pair in EAX:EDX
.
Here is the source: http://en.wikibooks.org/wiki/X86_Assembly/High-Level_Languages
Upvotes: 2