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.
Here's how it looks:
http://vogons.zetafleet.com/viewtopic.php?t=24499&sid=9ae1bdc243d05d347f08553e7ad73c44
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:
http://svn.freepascal.org/svn/fpc/trunk/rtl/i386/fastmove.inc
(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).
Starting with r3851 http://sourceforge.net/p/dosbox/code-0/3851/, the x86 FPU emulator code is used when running in 64-bit mode on an x86 CPU. Running r3869, I am getting accurate results in a 64-bit build.