I have been working on making an x86_64 long mode operating system and I came across a bug that confuses me. My goal is to be able to initialize and use floating point variables in the kernel which is written in c++. I expected it to work much the same as initializing a char, int, or long. All of which work. However it instead causes the cpu to reboot. I have tried adding floating point variables to a previous program that uses GRUB to boot into the kernel (in protected mode), and they worked there. I have tried to research this issue, but have found nothing but dead ends talking about division by zero exceptions. The entire code for the boot loader and the very beginnings of the kernel can be found on Github. The issue occurs when when I add a line that initializes a floating point number anywhere in the code that is executed. Ex. changing
extern "C" void kmain(){
clrscr(7);
set(10, 10, 0);
for(;;);
}
to
extern "C" void kmain(){
float test = 8;
clrscr(7);
set(10, 10, 0);
for(;;);
}