Message board for the users of flat assembler.
> Linux > system call in 64-bits
Hi, someone knows when I must use 64-bit registers in a system call? Only in the case of memory pointers?
When I must use stack to pass parameters, is there a difference with the 32-bit way?
Is there a way to make system calls using SYSCALL? It's supposed to be faster than INT but I don't see any example using it.
I'm very newbie on linux, I'd just assembled the "hello 64-bit world" example some minutes ago (and tested SYSCALL without success)
|16 Feb 2006, 23:57||
A.2.1 Calling Conventions
3.2.3 Parameter Passing
Just dl the pdf and read it, especialy Figure 3.4: Register Usage (hard to convert the table into this reply, there are 3 collumns:
Register, Usage, Preserved across function calls).
The pdf haven't helped me too much, here are my practical experiences (and they are in contradiction with infos from pdf):
It looks like there aren't parameters passed on the stack, and limit is max 6 params, but I'm not sure and I have never used more than 4 args to syscall.
I pass args in this way:
1st in rax = syscall_number, mov EAX,syscall_number is enough to set RAX
2nd in rbx
3rd in rcx
4th in rdx
(I have never passed more args)
For memory pointers use lea reg64,[...] as you have written
For values use 32-bit reg which is zero extended to 64 bit by CPU itself
this can reduce opcode size (e.g. xor eax,eax is enough for zeroing RAX reg and produce only 2 byte opcode instead of 3 byte xor rax,rax (1 byte rex prefix + 2 bytes opcode)
If your ELF is under offset 100000000h, you can use lea reg32,[...] for addressing (saving 1 byte of REX prefix in opcode), but I don't suggest it to you because you cannot load your ELF at RIP=100000000h or higher.
|17 Feb 2006, 08:23||
|17 Feb 2006, 13:50||
< Last Thread | Next Thread >
Copyright © 1999-2019, Tomasz Grysztar.
Powered by rwasa.