Returning long long value in i386 assembly?
Posted: Tue Mar 09, 2021 11:17 pm
Currently making a memory size detecting function in i386 assembly(C wont work because of compiler optimization), need to use long long values.
The Place to Start for Operating System Developers
http://f.osdev.org/
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.
Code: Select all
__attribute__((optimize("-O0"))) void func();
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.
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.