inline asm: operand type mismatch for `in'

1

Error: operand type mismatch for `in'

The line generating this is: inb %%eax, %%edx

I tried this: inb %%eax, $0x00000064 and inb %%eax, $0x64

didn't change the output. I also tried with 'in' instead of 'inb' but I'm taking shots in the dark at this point.

Any ideas?

c
assembly
x86
att
asked on Stack Overflow Nov 23, 2014 by sqlbuddy • edited Nov 23, 2014 by Jester

1 Answer

2

"inb" means that you execute a mnemonic command "in" on the operands of size byte (8-bit). inw is for words (16-bit), inl is for long words (32-bit) and inq is for quad (on 64 bit machines). The %eax register is 32-bit, which consists of %ax (16-bit). The %ax register, in its turn, consists of high 8 bits (%ah) and low 8 bits (%al). Thus, if you are to use "inb", you should use %al or %ah, e.g.,

inb %%al, %%dl # from source %%al 8-bit to destination %%dl 8-bit.

To use "in" with %eax, you need to append "l" to the command (or to omit the letter as some compilers can infer the type). That is,

inl %%eax, %%edx

should do fine.

answered on Stack Overflow Jan 17, 2016 by NeoSer

User contributions licensed under CC BY-SA 3.0