Search code examples
cassemblyx86attosdev

Writing an OS; asm keyword troubles


asm("lidt (%0)" : : "p"(&idtr));

The above statement will be used to define an IDTR in my IA-32 operating system. For some reason though, the compiler chokes on it:

kernel/kernel.c:52:2: error: invalid 'asm': invalid expression as operand
  asm("lidt (%0)" : : "p"(&idtr));
  ^

Does anyone know what I'm doing wrong here? If you need any more context to answer my question, please say so and I will gladly provide it.


Solution

  • Apart from the instruction, you got every possible thing wrong. The correct way:

    asm("lidt %0" : : "m"(idtr));