I was thinking of using a far jump to set the code segment (CS) register. Getting into why I'm doing this and why I'm dealing with segmentation at all would take a while, so bear with me and consider it an academic exercise. I can't seem to get the syntax right.
Error: suffix or operands invalid for 'ljmp'
I know it's foolish to put cs
into another register, but I figured I'd try it since using %0
wasn't working (the ax
register doesn't work either).
I'm looking at some code that compiles fine and this is driving me crazy, since I thought ljmp
would be the same: __asm volatile ( "lcall $0x8, $far_call" );
I would of course welcome other hacky ways of affecting the CS register.
void set_cs(u16 cs) {
__asm__ volatile (
"mov %0, %%ax \n\t"
"ljmp %%ax, $fake_label \n\t"
"fake_label: \n\t"
:
: "r" (cs)
: "ax"
);
}