ksherlock / mpw

Macintosh Programmer's Workshop (mpw) compatibility layer
238 stars 21 forks source link

MrC Floating point division broken #32

Closed steventroughtonsmith closed 6 years ago

steventroughtonsmith commented 6 years ago

Hey there! I'm seeing a reproducible MrC bug with mpw 0.8.0/MrC C Compiler 4.1.0f1c1; floating point division does not work properly.

test.c

#include <stdio.h>

int main()
{
   float SCALE = 1.0f/16.0f;
   printf("Scale = %f", SCALE);
   return 0;
}

Compiling

mpw MrC test.c
mpw PPCLink test.c.o {SharedLibraries}StdCLib {PPCLibraries}StdCRuntime.o {PPCLibraries}PPCCRuntime.o -o test

With the above, running MrC on real hardware emits code that prints '0.062500'. Running MrC under mpw prints '625.000000'.

I am running a slightly older build of mpw so my apologies if you're already on top of this! =)

mpw-orig

mpw-ksherlock
ksherlock commented 6 years ago

Could be worse... SC compiles it down to 0.807692 or 062500.000000, depending on if it's a compile time constant or not.

steventroughtonsmith commented 6 years ago

Aha! Not just me then 🙃 So it's not just the one tool, rather something in the emulation outright? Anything I can do to help triage?

carfesh commented 6 years ago

I haven't looked into it much, but Petter recently committed a fix for 64-bit division in the WinFellow code - you might try and see if this fixes it?

https://github.com/petschau/WinFellow/commit/f5eeb1a1f729477f9920d2c25173b88bad9527bc

steventroughtonsmith commented 6 years ago

I can confirm that the above patch does not fix the issue here, from what I can tell.

ksherlock commented 6 years ago

I fixed some problems with the SANE FX2DEC formatting which should fix this issue (but not the 1.0/16.0 = 0.807692 SC issue).

mpw-0.8.2.zip

steventroughtonsmith commented 6 years ago

It works! Safe to close this on my end. Thanks!