gcc inline assembler syntax for ljmp seg:offset
Posted: Tue Jul 16, 2024 12:02 pm
Dear OSDev Community,
I am currently hanging with my inline assembler line for the long jump. I tried many thinks and googled for hours, but I am still not able to produce something that will compile.
I am in 32bit PMode and setup a new GDT. Now I want to do a far jump to update the CS. Here is what I use:
The compiler error is that there is an undefined reference to "$8" - But the $ should indicate an immediate value. If I try without the $ I get an error "operand mismatch".
Why does GCC think the $8 is a symbol and not an immediate value?
Best regards
Sebi
I am currently hanging with my inline assembler line for the long jump. I tried many thinks and googled for hours, but I am still not able to produce something that will compile.
I am in 32bit PMode and setup a new GDT. Now I want to do a far jump to update the CS. Here is what I use:
Code: Select all
#define GDT_CODE32_SEL 0x08
#define GDT_DATA32_SEL 0x10
(...)
asm volatile (
"lgdt %0;"
"ljmp $%1, $1f;"
"1:"
"movw %%ax, %%ds;"
"movw %%ax, %%es;"
"movw %%ax, %%fs;"
"movw %%ax, %%gs;"
"movw %%ax, %%ss;"
:
: "m" (GlobalDescriptorTableDescriptor), "i" (GDT_CODE32_SEL), "ax" (GDT_DATA32_SEL)
:
);
(...)
Why does GCC think the $8 is a symbol and not an immediate value?
Best regards
Sebi