'x86 port access: possible without explicit assembly?

I have a class IOport looking like:

class IOport {
    uint16_t address;    
  public:
    IOport(uint16_t a) : address(a){};

    void outb(uint16_t val) const { asm volatile("outb %0, %1" : : "a"(val), "Nd"(address)); }

    ...
}

It is used to provide access to IOPorts on x86.

Just out of curiosity: Is there a way to achieve access without using assembler code manually and let the compiler generate the code accordingly?

I'm trying bare-metal x86 using gcc.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source