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.
inline void outb(unsigned int port,unsigned char value) // Output a byte to a port
{
asm volatile ("outb %%al,%%dx"::"d" (port), "a" (value));
};
inline void outw(unsigned int port,unsigned int value) // Output a word to a port
{
asm volatile ("outw %%ax,%%dx"::"d" (port), "a" (value));
};
inline unsigned char inb(unsigned short port)
{
unsigned char ret_val;
asm volatile("inb %w1,%b0"
: "=a"(ret_val)
: "d"(port));
return ret_val;
};
If it works on FreeBSD then I don't think there is anything wrong with your code. You probably need to rebuild gcc with x86 support if it doesn't already include it and tell it that you want it to produce x86 code. I am pretty sure Apples version of gcc doesn't produce x86 code by default