programmer
programmer

Reputation: 813

Operand type mismatch for in - gcc inline assembly

I have some C code that uses the inb instruction in inline assembly. I heard that inb takes operands that have a size of 8-bits. AL and DL are 8 bits, so why won't this work?

__asm__ __volatile__("inb %al, %dl");

It says "Operand type mismatch for in". If it matters, I have the ".code16gcc" at the top. All help is appreciated.

Upvotes: 2

Views: 767

Answers (1)

prl
prl

Reputation: 12435

Two things: In AT&T-style assembly, the destination operand is last, and the port number is 16 bits even when the data is 8 bits. So:

    inb %dx, %al

Upvotes: 1

Related Questions