Code: Select all
gdtr DW 0 ; For limit storage
DD 0 ; For base storage
setGdt:
MOV AX, [esp + 4]
MOV [gdtr], AX
MOV EAX, [ESP + 8]
MOV [gdtr + 2], EAX
LGDT [gdtr]
RET
And I understand this just fine, but the issue arises when trying to this in in extended gcc inline assembly
Code: Select all
struct GDTR
{
std::uint16_t base;
std::uint32_t limit;
};
void load_gtdr(GDTR gdt_register)
{
asm("gdtr: DW 0 DD 0");
asm("mov (%0) (gdtr)" : "=m"(gdt_register.base));
asm("mov (%0) (gdtr + 2)" : "=m"(gdt_register.limit));
asm("lgdt (gdtr)");
}
Code: Select all
/tmp/ccqXDjYf.s:22: Error: no such instruction: `dw 0 DD 0'
/tmp/ccqXDjYf.s:26: Error: found '(', expected: ')'
/tmp/ccqXDjYf.s:26: Error: junk `(%ebp))(gdtr)' after expression
/tmp/ccqXDjYf.s:26: Error: number of operands mismatch for `mov'
/tmp/ccqXDjYf.s:30: Error: found '(', expected: ')'
/tmp/ccqXDjYf.s:30: Error: junk `(%ebp))(gdtr+2)' after expression
I don't want. And the other errors, well, I'm having a hard time debugging.
I'm also more familiar with intel synax as oppsed to AT&T, but I'm trying
to change that.