Hi,
I have a problem withmy custom build OS based on XV6 with the floating point. If I divide for example 10 / 0.75 it is going to crash.
I have tried all the options on the gcc compiler with no success. Maybe it is a problem in qemu on a Mac with a silicon chip?
Has someone an idea how to fixed it?
Kind regards,
Rober
Floating Point
- bellezzasolo
- Member

- Posts: 163
- Joined: Sun Feb 20, 2011 2:01 pm
Re: Floating Point
What instruction set is it using, have you enabled the necessary CPU flags?
Whoever said you can't do OS development on Windows?
https://github.com/ChaiSoft/ChaiOS
https://github.com/ChaiSoft/ChaiOS
Re: Floating Point
These are my flags for QEMU .
QEMUOPTS = -net none -hda xv6.img -hdb fs.img -smp cpus=$(CPUS) -m 8G $(QEMUEXTRA) -vga std -rtc base=localtime -M pc -cpu qemu64,+sse4.1,+sse4.2
QEMUOPTS = -net none -hda xv6.img -hdb fs.img -smp cpus=$(CPUS) -m 8G $(QEMUEXTRA) -vga std -rtc base=localtime -M pc -cpu qemu64,+sse4.1,+sse4.2
- bellezzasolo
- Member

- Posts: 163
- Joined: Sun Feb 20, 2011 2:01 pm
Re: Floating Point
In the OS to use SSE instructions you need to enable it in CR4 (OSFXSR), and likewise for X87 you need the right CR0 (!EM).
Whoever said you can't do OS development on Windows?
https://github.com/ChaiSoft/ChaiOS
https://github.com/ChaiSoft/ChaiOS
Re: Floating Point
Hi bellezzasolo,
Thank you for your answer and it is working now. I get only a crash when I pass a float to the printf routine!
Do you know what causes this?
Kind regards,
Robert
Thank you for your answer and it is working now. I get only a crash when I pass a float to the printf routine!
Do you know what causes this?
Kind regards,
Robert
-
Octocontrabass
- Member

- Posts: 6275
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Floating Point
It's hard to say for sure without more information about the faulting instruction, but the problem might be that your stack isn't correctly aligned.
Re: Floating Point
Hi,
Is it possible for you to look at my project to see what is wrong?
Maybe it is a linker or compiler option.
Thank you in advance.
Kind regards,
Robert
https://github.com/robert-krook/xv6-master
Is it possible for you to look at my project to see what is wrong?
Maybe it is a linker or compiler option.
Thank you in advance.
Kind regards,
Robert
https://github.com/robert-krook/xv6-master
Re: Floating Point
Hi,
I think I found it. I have added the flag -mpreferred-stack-boundary=3 to the gcc compiler and it is working now.
Thank you for the tip
Kind regards,
Robert
I think I found it. I have added the flag -mpreferred-stack-boundary=3 to the gcc compiler and it is working now.
Thank you for the tip
Kind regards,
Robert