Can't force the use of 64-bit registers in GCC inline assembly

Viewed 1543

I'm trying to make some things with GCC Inline Assembly, in this case, make a Syscall, but I want to force use of 64bit registers (rax, rdi, rsi, ...) instead of 32bit ones (eax, edi, ...), but I tried a lot of ways, and nothing.

void syscall(uint64_t arg1, uint64_t arg2) {
   // arg1 -> rax        arg2 -> rdi
   __asm__("syscall" : : "a" (arg1), "D" (arg2));
}

When I compile that I get:

mov eax, 60
syscall

I'm in a function, so "edi" is being get from arguments, but like you can see is "eax", I want to use rax.

How can I force 64bit registers instead of 32bit ones?

1 Answers
Related