The DOS version of the Free Pascal Compiler ( http://www.freepascal.org/ ) wouldn't run on non-i386 versions of DOSBox, so today I spent some time debugging DOSBox until I found the problem. Apparently FPC (and FPC-compiled programs) uses the FPU to copy memory blocks via the fild & fistp instructions, and since DOSBox converts int64 to double, some precision is lost and the data is garbled.
The reason some people are experiencing problems and others aren't is because dosbox on i386 uses the native x87 FPU and works fine. However 64-bit linux distros ship a 64-bit DOSBox, which doesn't work.
The problem affects not only Free Pascal, but also programs, compiled with it. Here's the code that breaks:
(procedures Forwards_IA32_3 and Backwards_IA32_3)
Apparently this weird method of copying data was the fastest way to copy data on the original Intel Pentium and Pentium MMX, so I it's probably also used in a lot of games from the Pentium era (and maybe other compilers as well).
Log in to post a comment.