Page 1 of 1

Regarding Negative point & floating point comparisions

Posted: Mon Apr 23, 2007 4:46 am
by sampath
Hi All,
I am developing an os in C for based on x86 arch. I have done my
booting code and switch to PM mode. Once the control comes to kernel
when I try to declare float or signed int with negative value and then
use compare statements it's giving wrong results. Some times it skips
the comparison part itself.

Some body pass on some clue to resolve this issue...


Tx,
Sampath S

Posted: Mon Apr 23, 2007 10:48 am
by XCHG
Are you sure the FPU is initialized? use the FINIT instruction in order to initialize the FPU.

Posted: Tue Apr 24, 2007 6:11 am
by sampath
No I have not done Initialization. Do I need to do FINIT explicitly???can i do it after switching to PM mode.???

Posted: Tue Apr 24, 2007 6:24 am
by mystran
You can init the FPU whenever you please. But if negative signed integers are giving you wrong results, then there's something more wrong than just uninitialized floating point unit, because integers are integers whether they are signed or not, and should work correctly with or without an FPU installed (ofcourse anything post-386 always has FPU but still).

Could you give an example where signed integer comparison gives you wrong results?

Posted: Wed Apr 25, 2007 6:08 am
by Solar
And check whether it's perhaps your print function not being able to print the results correctly...