inline assembler, register of function return value...
in some of our code (C++ interpreter) we have inline assembler code to to be able to call vararg functions (assembler needed to pass the varargs in the correct registers). According to the gcc asm docs the return value of a function call are always returned in the rax register. This holds also for Intel icc, except when the function returns a C++ object. In that case, I found by looking in the debugger, that Intel icc returns the object reference in rdi. Is this an icc particularity or is this documented behavior. Here a snip of out code:
Write a dummy function in C++that takes example arguments of type and number, and returns the type that you wish for your ASM routine. Then compile this file with the option switch that creates an assembler source file (omit the binary code and line numbers. Then examine how the arguments go into and come out of the listing. Follow this in your program.
Note, you will need to consult a reference as to which registers (r?x as well as xmm? etc) that are temporary and which require preservation.
Note, the register usage is different between x32 and x64.