0

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?

  • 1
    The compiler complains about `in` and `out` but the code ever mentions `inb` and `outb`. Are you sure those are the lines the compiler is complaining about ? – Unimportant Feb 14 '19 at 19:30
  • 1
    Mystery solved, I was compiling it with -masm=intel... :facepalm: –  Feb 14 '19 at 19:35

1 Answers1

1

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

  • 1
    Note that it's possible to write the asm such that it compiles whichever asm syntax you are using. Check out [Multiple assembler dialects](https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Multiple-assembler-dialects-in-asm-templates) in the docs. – David Wohlferd Feb 15 '19 at 02:12