I have the following c code (run in protected mode, all segments well defined):
Code: Select all
extern void _printcool();
extern void _wait();
int kmain()
{
_printcool();
while(1==1){}
return 0;
}
Code: Select all
[bits 32]
global _printcool
global _wait
_printcool:
mov byte [0xB8000], 'R'
mov byte [0xB8001], 0x52
ret
_wait:
jmp _wait
nasm -f elf asmfile -o asmfile.o
gcc -ffreestanding -m32 -fno-pic -fno-pie -c kernel.c -o kernel.o
ld --oformat binary -Ttext 0x1000 -melf_i386 asmfile.o kernel.o -o kernel.bin
Then I run my bootloader with this kernel, like before, but it triple fault every time.
The ret is responsible of the triple fault, but I don't understand what should I do, I think the problem comes from the stack, I dont know how to clean it before using ret instruction.
Thank you !