Search code examples
cosdevprotected-mode

operand type mismatch for `out', 'in'


I have this function:

uint8_t getcmosflpd(void)
{
    uint8_t c;
    outb(0x70, 0x10);
    c = inb(0x70);
    return c;
}

When I compile it, I obtain this errors:

/tmp/ccMmuD7U.s:28: Error: operand type mismatch for `out'
/tmp/ccMmuD7U.s:39: Error: operand type mismatch for `in'

This are my outb and inb functions:

static inline void outb(uint16_t port, uint8_t val)
{
    asm volatile ("outb %0, %1" : : "a"(val), "Nd"(port));
}

static inline uint8_t inb(uint16_t port)
{
    uint8_t ret;
    asm volatile ("inb %1, %0"
                   : "=a"(ret)
                   : "Nd"(port));
    return ret;
}

What's wrong?


Solution

  • I was compiling with -masm=intel. Always check your compiler flags!