I forgot to mention: we're not loading a pointer. The operand being passed via inline ASM is the GDTR struct itself, not a pointer to said struct. This has two advantages: the compiler can generate the pointer however it wishes instead of loading it into a register, and the compiler is aware that the value of the struct has significance instead of just the value of the pointer to the struct.bloodline wrote:Shouldn't the first opcode be lgdtl (%0), as we are loading a pointer?
That last bit is one of the many reasons why inline assembly is hard. The compiler assumes values not used as inputs or outputs have no significance to the inline assembly, so if you pass a pointer to inline assembly, the compiler only sees the value of the pointer as being significant, and not the object it points to. You can use a "memory" clobber to tell the compiler that the inline assembly may affect values other than its inputs and outputs, but then the compiler must spill all objects to memory.
None of that is a problem if you use an external function written in assembly.
I don't think that's a supported use case for inline assembly. There's a function attribute you can use, but it's specific to x86 and requires some extra compiler options you may not want to use.bloodline wrote:I attempted to build my interrupt stack frame using inline asm, but I must have made a mistake somewhere as it caused the interrupts to not return properly, so currently my int handler code is in a separate asm file... I will attempt to do it inline again when I get better at x86 asm.