64 bit mode, inline assembler, "outl %0,%w1" compi

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
rjying
Posts: 22
Joined: Tue Jan 15, 2008 12:52 am

64 bit mode, inline assembler, "outl %0,%w1" compi

Post by rjying »

wrote the inline assembler in the C code:
void outl(unsigned short port,unsigned long vaule)
{
__asm__ __volatile__ ( "outl %0,%w1" ::"a"(vaule),"d"(port));
}
But issue error when it's compiled.
that prompted, %0 refers "rax".
But the outl instruction only refers 32bit register.
I can modify "outl %0,%w1" to "outl %%eax,%w1".

But I hope use other way to fix it, just like %0 to use the input parameters.
Thanks
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

OUTs (and INs) only works with al/ax/eax and dx/constant as its operands. Having GCC choose the registers will only give you trouble since instead of the few options that are actually legal, it may choose practically everything.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
rjying
Posts: 22
Joined: Tue Jan 15, 2008 12:52 am

Post by rjying »

Thanks
Do you mean that I must use the "%%eax" to fix it?
Post Reply