VOGONS


3 Divided by 2 is 2? Math Support?

Topic actions

First post, by Gwhite

User metadata
Rank Newbie
Rank
Newbie

I have a huge amount of enginering software written in a DOS version of the APL language that I need to keep running. Microsoft's support for DOS is increasingly pathetic, so I figured DOSBox might save my bacon.

There seems to be a bit of a problem with math operations. All the computations I've tried produce only integer results. This is running the latest version (0.63) of DOSBox, and it occurs on a couple different couple-GHz Pentium machines, so it isn't a hardware problem. This is running in Windows XP Pro.

The APL interpreter claims that it will run OK without a math coprocessor (i.e. a 387 chip if you are using a 386), but one is strongly recommended. In some mainframe APLs, all computations were done using double precision, but I have no idea if that applies to the PC version.

My recollection is that the math coprocessor functions were built into the 486, so this may be an issue with the incomplete 486 emulation. On the otherhand, I know someone who is running a different engineering package, and he hasn't had a problem. It appears to be something specific to running the APL interpreter in DOSBox.

In any event, I can't use DOSBox at the moment. If any developers want to look into this, I can provide them with either a "canned" program that will crash with an error, or a complete freeware APL interpreter to play with. I could even put together a program that would run & display a list of calculations.

Any ideas or suggestions would be appreciated.

Thanks!

Reply 1 of 20, by h-a-l-9000

User metadata
Rank DOSBox Author
Rank
DOSBox Author

A lot of work has been done since 0.63.
DOSBox SVN Builds
Maybe your problems have also been fixed.

1+1=10

Reply 2 of 20, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

The fpu is emulated using double-precision in dosbox 0.63, which CAN
result in odd results like 3/2=2, especially when it comes to the output
conversion of some compiler libraries.
The next version uses an 80 bit precise fpu emulation on x86 systems,
so you should try a newer version as HAL said.

Reply 3 of 20, by Gwhite

User metadata
Rank Newbie
Rank
Newbie

Thanks! I'll try CVS-Compile/AEP-EMU version. Unfortunately, the web site appears to be down at the moment.

There is a huge amount of valuable work that was done in DOS for scientific & engineering problems. I even know one guy who still sells a specialized CAD package that only runs in DOS. I know a lot of DOSBox development is for games, but it could also save a lot of other software from the dustbin. Thanks to everyone for supporting this effort.

Reply 5 of 20, by Gwhite

User metadata
Rank Newbie
Rank
Newbie

Well, I downloaded the latest CVS compile, and it works better in many ways, but it's still returning integers for all calculations. I'm at a bit of a loss for what to do next, but I will be happy to work with anyone who understands the inner workings to try to chase this down.

In the meantime, I'm really excited about DOSBox. It's showing enormous promise for a bunch of long standing problems I've had with running DOS apps under Windows. I've got another application at work that I will try it on tomorrow.

Thank you!

Reply 6 of 20, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

More likely something with those bin2dec/asc opcodes than
the fpu, maybe you can upload samples (like non-copyrighted
executables) that show the problem.

Reply 7 of 20, by Gwhite

User metadata
Rank Newbie
Rank
Newbie

Because the application is actually a programming environment, I can create a small executable that will demonstrate the problem. I'll rig it up to run a sample set of calculations with a copy of the correct answers on-screen I'll park it on my website and post a link to it on Monday.

Thanks!

Reply 8 of 20, by Gwhite

User metadata
Rank Newbie
Rank
Newbie

OK, here's a test program that will re-create the problem at will:

http://users.rcn.com/gwhite/APL/DBOXTEST.zip

It works fine if run directly in XP, both on a Dell system and an IBM laptop, but it
produces only integer results in DOSBox.

I also discovered today that a previous version of the APL interpreter seems to work OK in this regard. I have no idea why something so fundamental would change between successive versions.

I can create quite a wide range of test programs using the "run time interpreter" APL system, and I'm hoping this approach will help with the debugging process. If anyone needs more info on exactly how this program was created, let me know.

Thanks!

Reply 9 of 20, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

They need the fpu precision exception bit in their
floating output routines. It is ignored because of
speed reasons, but you can enable it by out-commenting
the line
#define WEAK_EXCEPTIONS
at top of fpu_instructions_x86.h

You can try some CVS build from around last december,
there this option was always configured to provide the
maximal possible fpu exception flags.

Reply 10 of 20, by Gwhite

User metadata
Rank Newbie
Rank
Newbie

Thanks! That was quick. I'll have to look into an older CVS build, or getting set up to compile the source myself. The last time I worked with a compiler was about 20 years ago, so I'm a bit rusty.

In the meantime, I'd like to suggest that a config file switchbe installed for this in future releases. I can certainly get set up to compile my own custom versions. However, I've already found a couple other minor bugs, and it will be hard for folks to investigate them if they have to have a custom compiled version to run the executables I can create.

If this is either A) a pain in the neck, or B) not worth the bother compared to other work, I can muddle along. The older interpreter that doesn't have the integer problem won't create executables, but I think can rig up something. It will just be a bit more work to install if someone wants to run something to duplicate any problems I find.

I have a very large suite of test routines for my APL software, which is a microwave circuit analysis tool. Now that this issue is somewhat resolved, I can start trying to run those and see what happens. When DOSBox can pass all those tests without any hiccups, it will be pretty bulletproof.

Thanks again for your help!

Reply 11 of 20, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Hm, i don't think this'll be made switchable, please keep in mind that
the goal of dosbox are dos games. I think ykhwong has some older
builds on his homepage, so you don't need to build it yourself.

Maybe your compiler suit has an option to not rely on fpu exception
flags, or ignore fpu exceptions, so it should behave like your old compiler.

Reply 12 of 20, by Gwhite

User metadata
Rank Newbie
Rank
Newbie

I'll check out ykhwong's archives. I realize that the primary thrust is to support old games, but I'd be surprised if there isn't one or two out there that would run afoul of this as well. I don't know if there is a downside to using a switch. I suppose the compiled code will be more compact if it's left out. In any event, I figured it never hurts to ask. Besides, if you knew how much fun it is to program in APL, you'd think it was a game too. 😀

The problem with the app I'm running is that it isn't compiled. I'm using commercial APL interpreters that I don't have the source code to. The code I'm running is written in APL, and then run in the interpreter environment. The executable test program was produced with a "run-time interpreter" that bundles the APL code and the interpreter into a tidy package. Most of the time folks work directly in the interpreter. The run-time trick is just if you have a small routine you want to pass along to folks who don't have the interpreter and/or aren't familiar with APL.

Reply 13 of 20, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

I compiled an up to date CVS (as up to date as anonymous CVS can be 😀) with the change wd wrote above.
You can get it at (link deleted now - file was received 😀)
Please pm when you have downloaded it, I can't provide it for everyone 😀
Hope it helps, so you know it's just this little change.
When (hopefully soon) the new version of Dosbox is released I can make a built of the release source for you as well with the above change.

If it works and you end up using Dosbox for all this, you may consider a donation to the Dosbox team http://sourceforge.net/project/project_donati … ?group_id=52551
I don't know what they do with the money but I think it is a nice gesture when you use it in a commercial field. (This is just my opinion and I'm not part of the Dosbox team, so don't hold my speech against them 😀)

Last edited by Dominus on 2006-03-22, 23:28. Edited 1 time in total.

Reply 14 of 20, by Gwhite

User metadata
Rank Newbie
Rank
Newbie

Many thanks to both Dominus and to wd! I downloaded the CVS Dominus compiled and it works like a champ! wd nailed it. You guys rock!

Now I can get to back testing & hunting for more bugs...

Reply 15 of 20, by tabo

User metadata
Rank Newbie
Rank
Newbie

I'm running the ancient Pocket APL using the OS X DOSBox on an Intel MacBook, and I'm having a similar problem: Functions show up as variables, they fail to execute, etc.

Pocket APL ran fine under Virtual PC, but has graphics issues under Parallels and VMWare Fusion. DOSBox seems to get the closest, but Pocket APL is only sort of half-working. Would a more recent (or tweaked) build solve my problem?

Thanks...

-- Jeff

Reply 16 of 20, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Would a more recent (or tweaked) build solve my problem?

No because exception flags are not supported on macos as the emulation
is done in highlevel language.

Reply 17 of 20, by TeaRex

User metadata
Rank Member
Rank
Member

Maybe this is a very dumb idea, as I don't have a Mac myself (well except for an ancient 68k monster). But couldn't you run the Windows version of DOSBox under Parallels or some other tool that allows you to run Windows software?

--
Linards Ticmanis

tearex

Reply 18 of 20, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

If parallels passes the fpu stuff fine, it should work (you'll need to set
core=dynamic in the dosbox.conf for the 0.72 release).

Reply 19 of 20, by tabo

User metadata
Rank Newbie
Rank
Newbie

Argh. Setting core=dynamic didn't help.

It's weird: the only Mac emulators which have ever run Pocket APL correctly are SoftWindows (remember that?) and Virtual PC. Both VMWare Fusion and Parallels have graphics issues, and DOSBox has the odd glitches described above.

Anyone who comes up with a fix gets an autographed 8x10 of the Desperate Housewives cast. I'm not kidding.

-- Jeff