From 733019e96b8b344cff2d182028ad58b9df9e0cdc Mon Sep 17 00:00:00 2001 From: Freeman Date: Mon, 22 Jun 2020 00:42:17 +0300 Subject: [PATCH] FPU support added --- RTL/System.pas | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/RTL/System.pas b/RTL/System.pas index 8ee98e4..410f126 100644 --- a/RTL/System.pas +++ b/RTL/System.pas @@ -149,6 +149,13 @@ procedure _Halt0; procedure _HandleFinally; procedure _StartExe(InitTable: PPackageInfo); +var + Default8087CW: Word = $1332; // for Extended type + +procedure InitFPU; +function Get8087CW: Word; +procedure Set8087CW(Value: Word); + function UpCase(Ch: KolibriChar): KolibriChar; implementation @@ -217,6 +224,29 @@ begin end; end; +procedure InitFPU; +asm + FNINIT + FWAIT + FLDCW Default8087CW +end; + +function Get8087CW: Word; +asm + PUSH 0 + FNSTCW [ESP].Word + POP EAX +end; + +procedure Set8087CW(Value: Word); +begin + Default8087CW := Value; + asm + FNCLEX + FLDCW Default8087CW + end; +end; + function UpCase(Ch: KolibriChar): KolibriChar; begin if Ch in ['a'..'z'] then