Returning long long value in i386 assembly?
-
- Member
- Posts: 70
- Joined: Tue Jul 14, 2020 4:01 am
- Libera.chat IRC: clementttttttttt
Returning long long value in i386 assembly?
Currently making a memory size detecting function in i386 assembly(C wont work because of compiler optimization), need to use long long values.
Re: Returning long long value in i386 assembly?
I believe the usual convention is to return the value in edx:eax.
edx holds the 32 most significant bits and eax the 32 least significant ones.
edx holds the 32 most significant bits and eax the 32 least significant ones.
Re: Returning long long value in i386 assembly?
Yes. As the wiki says: "The return value is stored in the eax register, or if it is a 64-bit value, then the higher 32-bits go in edx".kzinti wrote:I believe the convention is to return the value in edx:eax.
edx holds the 32 most significant bits and eax the 32 least significant ones.
Btw, if you want to disable optimizations in GCC, you can use the 'optimize' attribute:
Code: Select all
__attribute__((optimize("-O0"))) void func();
Re: Returning long long value in i386 assembly?
Be very careful about reading/writing random memory addresses. This might have undesired side effects. UEFI and GRUB both provide memory maps; it may be better to use them.clementttttttttt wrote:Currently making a memory size detecting function in i386 assembly.
-
- Member
- Posts: 5568
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Returning long long value in i386 assembly?
It's not possible to detect installed memory. You must use the memory map provided by the firmware.clementttttttttt wrote:Currently making a memory size detecting function in i386 assembly
If your code behaves differently depending on compiler optimization, the problem is your code, not the compiler optimization.clementttttttttt wrote:(C wont work because of compiler optimization)
This is documented in the i386 psABI.clementttttttttt wrote:need to use long long values.