I'm trying to edit the IDT (interrupt Descriptor Table) and I have found this code which should give me access to the structure. But I didn't understand what the colon in the asm line is. I guess that it's some game with bitmaps in C, and this is somehow padding the instruction. But I couldn't find anything definitive.
If it helps, right now the compiler says: invalid 'asm': invalid expression as operand. Still fighting this one... :)
So, what is the colon doing there?
This is the extended asm syntax from gcc compiler. Here's a link describing the syntax:
asm ( assembler template
: output operands /* optional */
: input operands /* optional */
: list of clobbered registers /* optional */
);
and the example:
int a=10, b;
asm ("movl %1, %%eax;
movl %%eax, %0;"
:"=r"(b) /* output */
:"r"(a) /* input */
:"%eax" /* clobbered register */
);
- "b" is the output operand, referred to by %0 and "a" is the input operand, referred to by %1.
- "r" is a constraint on the operands. We’ll see constraints in detail later. For the time being, "r" says to GCC to use any register for storing the operands. output operand constraint should have a constraint modifier "=". And this modifier says that it is the output operand and is write-only.
- There are two %’s prefixed to the register name. This helps GCC to distinguish between the operands and registers. operands have a single % as prefix.
- The clobbered register %eax after the third colon tells GCC that the value of %eax is to be modified inside "asm", so GCC won’t use this register to store any other value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With