It is possible to write an X86 OS without using X87 FPU?
Posted: Sun May 01, 2016 7:41 am
Hello!
I'm working on the Cosmos OS project (a C# operating system) that in end AOT compiles IL to X86 assembler.
As in X64 SSE is mandatory and X87 is no more used I tough would have making sense as we were using already SSE for float32 (called Single / float in C#) to use them for float64 (Called Double / double in C#) too so we will not need X87 anymore.
All was going well until the conv.i8 instruction was needed to be implemented and suddenly I discovered that there was no SSE instructions to convert float and double to long / Int64! For all the other integer types there is CVTTSS2SI but this does not works for Int64... on internet I have seen some sites referring to a CVTTSS2SIQ but NASM says this instruction does not exist. Probably it has been added for X64...
I've tried to implement a Int64 conversion using double to two packed integer but I obtain a wrong value interpreting the two integers as long:
My idea is to never initialize X87 so to use MMX instructions and register freely without having to have always to clear the MMX registers after any usage or FPU will be in a corrupt state.
Thanks for your help.
I'm working on the Cosmos OS project (a C# operating system) that in end AOT compiles IL to X86 assembler.
As in X64 SSE is mandatory and X87 is no more used I tough would have making sense as we were using already SSE for float32 (called Single / float in C#) to use them for float64 (Called Double / double in C#) too so we will not need X87 anymore.
All was going well until the conv.i8 instruction was needed to be implemented and suddenly I discovered that there was no SSE instructions to convert float and double to long / Int64! For all the other integer types there is CVTTSS2SI but this does not works for Int64... on internet I have seen some sites referring to a CVTTSS2SIQ but NASM says this instruction does not exist. Probably it has been added for X64...
I've tried to implement a Int64 conversion using double to two packed integer but I obtain a wrong value interpreting the two integers as long:
Code: Select all
SystemVoidCosmosCompilerTestsBclSystemDoubleTestExecute.IL_01BD.0B: ;Asm
movsd XMM0, [ESP]
SystemVoidCosmosCompilerTestsBclSystemDoubleTestExecute.IL_01BD.0C: ;Asm
UNPCKLPD XMM0, XMM0 # This should create two copies of the same double in the low and in the high part of the XMM register
SystemVoidCosmosCompilerTestsBclSystemDoubleTestExecute.IL_01BD.0D: ;Asm
CVTTPD2DQ XMM1, XMM0
SystemVoidCosmosCompilerTestsBclSystemDoubleTestExecute.IL_01BD.0E: ;Asm
movlpd [ESP], XMM1
Thanks for your help.