A friend of mine sent me an assembly function with a description like this:
Function Foo
Parameters:
EAX -> unsigned 32 bit integer
CL -> unsigned 16 bit integer
RDI -> unsigned 64 bit integer
Now I need to call this function from my C program and I solved the problem by doing this:
asm volatile (" \n\t\
mov eax, 0 \n\t\
mov cl, 1 \n\t\
mov rdi, 0x120000 \n\t\
call foo \n\t\
");
Which works but is a bit ugly and inconvenient. I thought about wrapping this inline asm in a function but I don't like it as a solution. I tried to declare the function as extern:
extern foo(uint32_t eax, uint16_t cl, uint64_t rdi);
And with this line, the compiler does not complain at all but the parameters are all messed up. Is there a way to simplify the calling of this function with extern? If not how do I have to modify the parameters to make it works with this technique?