I have a C function in my custom kernel that prints DEBUG on the top left corner.
I call that function using a different cs :
asm("lcall $0x28, $0x0");
(The code is copied at the beggining of the 0x28 code segment).
In the c function that prints the DEBUG message, I return using :
asm("lret;");
But when I execute the code, It triple fault milliseconds after showing the DEBUG message. If I just do :
asm("call $0x08, $0x100");
It works. ($0x08 is kernel code covering the whole memory, $0x28 is the 'debug' program code segment starting at 0x100).
I suppose the problem comes from the gcc asm generation as if I execute the same return but from NASM, the "retf" is working and no triple fault.