EtchedPixels / Fuzix-Compiler-Kit

Fuzix C Compiler Project
Other
49 stars 13 forks source link

The position of the hidden bit in upport6800/__cast2f.c is incorrect. #147

Closed zu2 closed 3 weeks ago

zu2 commented 3 weeks ago

The position of the hidden bit in upport6800/__cast2f.c is incorrect.

The bit should be 0x00800000, but is 0x01000000.

This causes an incorrect type conversion from integer to float.

This is not just a problem only with the 6800, but other architectures seem to have similar problems.

--- ../Fuzix-Compiler-Kit/support6800/__cast2f.c    2024-10-13 22:57:57
+++ support6800/__cast2f.c  2024-10-13 22:53:46
@@ -12,7 +12,7 @@
     }
     /* Move smaller numbers up until the first 1 bit is in the implied 1
        position */
-    while(!(a1 & 0x01000000)) {
+    while(!(a1 & HIDDEN)) {
         exp--;
         a1 <<= 1;
     }
@@ -27,9 +27,9 @@
     int exp = 24 + EXCESS;

     if (a1 == 0)
-        return a1;
+        return 0;
     r = a1;
-    while(!(r & 0x01000000)) {
+    while(!(r & HIDDEN)) {
         exp--;
         r <<= 1;
     }
@@ -42,9 +42,9 @@
     int exp = 24 + EXCESS;

     if (a1 == 0)
-        return a1;
+        return 0;
     r = a1;
-    while(!(r & 0x01000000)) {
+    while(!(r & HIDDEN)) {
         exp--;
         r <<= 1;
     }
EtchedPixels commented 3 weeks ago

Thanks