Programming, for all ages and all languages.
gerryg400
Member
Posts: 1801 Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia
Post
by gerryg400 » Sun May 30, 2010 6:15 am
I'm trying to tell port my syscall functions to x86_64 using the native parameter passing of the processor. So far I've got something like this.
Code: Select all
static inline uint64_t _Syscall4(uint64_t __n, uint64_t __p1, uint64_t __p2, uint64_t __p3, uint64_t __p4) {
long ret;
__asm__ __volatile__ ( \
"int $0x20\n\t"
: "=a" (ret)
: "D" (__n), "S" (__p1), "d" (__p2), "c" (__p3), "XXX" (__p4)
);
return ret;
}
There is no register constraint for r8 hence the XXX. If I don't have the constraints, gcc thinks I'm not going to use the parameters and they get optimised away. What can I do ? Thanks in advance.
If a trainstation is where trains stop, what is a workstation ?
Owen
Member
Posts: 1700 Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:
Post
by Owen » Sun May 30, 2010 6:32 am
Local Reg Vars
Just a note: If you're targetting x86_64, seriously use syscall/sysret instead of int. It is significantly faster.
gerryg400
Member
Posts: 1801 Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia
Post
by gerryg400 » Sun May 30, 2010 6:49 am
Cool, thanks I'll try that. I will use syscall or sysenter, but right now I'm just trying to get things working again. I'll still need to solve this problem won't I ?
If a trainstation is where trains stop, what is a workstation ?
gerryg400
Member
Posts: 1801 Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia
Post
by gerryg400 » Sun May 30, 2010 7:36 am
This appears to work. Do you think it's okay ?
Code: Select all
static inline uint64_t _Syscall4(uint64_t __n, uint64_t __p1, uint64_t __p2, uint64_t __p3, uint64_t __p4) {
long ret;
register long r8 asm ("r8") = __p4;
__asm__ __volatile__ ( \
"int $0x20\n\t"
: "=a" (ret)
: "D" (__n), "S" (__p1), "d" (__p2), "c" (__p3), "r" (r8)
);
return ret;
}
Thanks again in advance.
If a trainstation is where trains stop, what is a workstation ?