Jump to content
IGNORED

Question about Turbo Basic's math package


markmiller

Recommended Posts

@dmsc

I'm looking at the sources in dmsc's MADS disassembly of Turbo Basic (https://github.com/dmsc/turbo-dis/tree/master). I'm trying to port the math package to Fig-Forth, using its assembler, as an exercise in learning the TB math package. I'm also interested in seeing how Forth performs with it, instead of using the Atari math pack.

 

I've started with the random number generator, since I have a use for it. I know there's a standard algorithm for generating random numbers in Forth, but it generates integers. I'm trying to get an apples-to-apples comparison with Basic's RND() function.

 

I basically get the scheme Ostrowski used for generating random numbers, but there's something he did that's mystifying me. His algorithm gets a random number for each nibble in the 2nd through 6th BCD slots in the float he's generating, but he seems to be deliberately defeating the BCD scheme. He throws out any number less than 10 ($A). So, each nibble is only $A-$F. When I try to print out the random number, I get garbage. Here are some samples:

 

0.:>?=?;1:>:

0.<==>;;>?=<

 

What was he driving at by making these digits A-F?

 

I guess I foolishly thought this would be relatively straightforward! I've taken a cursory look at TB's other math operations, and nothing is jumping out at me, in terms of revealing a special numbering system Ostrowski used.

 

Also, what's the dispatch mechanism in TB? I've located the syntax table stuff, but every time I try to look up where a label like X_RND is being called (a JSR), I get nothing. So, I'm guessing there's an index table being generated during assembly that sets up the dispatch, and this is why calls like this are not showing up in the source code.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...