Jump to content
IGNORED

Assembly RND routine?


Willsy

Recommended Posts

Does anyone have any suggestions for a random number generator in assembly language? A routine that generates a number between 0 and 65535 would be fine.

 

I'm not satisfied with the Forth routine I have been using in TurboForth, so I'd welcome any suggestions.

 

If anyone has any ideas, and the routine is short enough, I'd like to add it to the TF V1.1 code.

 

I'll check MicroPendium etc but I thought I would give a shout out in case anyone has code already done, that they don't mind sharing.

 

Cheers

 

Mark

Link to comment
Share on other sites

 

Wow! I like that one! I managed to implement it with a little extra functionality and fit it into the spare space in bank 1 with 2 bytes to spare!

 

Thanks

 

So will you consider a 32K (4x8) ROM for the future version of Turboforth? Here's an idea, perhaps add the possibility for loading screens from ROM.

You could use the remaing space to include a standard library of words with super-duper fast access. I don't think the 64K EEPROMS are that much more expensive than 16K EEPROMS nowadays.

Link to comment
Share on other sites

 

Wow! I like that one! I managed to implement it with a little extra functionality and fit it into the spare space in bank 1 with 2 bytes to spare!

 

Thanks

 

So will you consider a 32K (4x8) ROM for the future version of Turboforth? Here's an idea, perhaps add the possibility for loading screens from ROM.

You could use the remaing space to include a standard library of words with super-duper fast access. I don't think the 64K EEPROMS are that much more expensive than 16K EEPROMS nowadays.

 

The current TurboForth lineage will end with V1.1 I think. I've taken it as far as I can in 16k.

 

TurboForth 2.0 will probably be 32 or possibly 64K. If I ever start it. Some of the features:

 

* Compile Forth code to native machine code (not threaded code) with inlining of certain words (e.g DROP DUP SWAP etc would be inlined).

* Multi-tasking

* Bitmap mode

* A full suite of DOS words built in (DIR, COPY, TYPE, FORMAT etc)

* Save/load memory image files

 

It will essentially be a self contained alternative operating system on a cartridge.

 

Marc Hull's idea of a multi-banked cart with RAM on it is the target (for me). Multi-tasking requires each task to have its own set of private variables, which can eat RAM, so the idea of 4K of ram in the cartridge is attractive.

 

Since Marcs cart contains Flash memory, you could also load/save/edit code to 'virtual blocks' contained in the Flash memory chip. You would have access to around 200 blocks actually on the chip, living inside the cartridge. If these were compiled and BSAVED then they would load instantly. :-)

 

We'll see. ;)

Link to comment
Share on other sites

  • 3 weeks later...

I'm probably a day late and a dollar short, and you are undoubtedly familiar with the following from TI FORTH:

 

: RNDW 83C0 DUP @ 6FE5 * 7AB9 + 5 SRC DUP ROT ! ;
: RND RNDW ABS SWAP MOD ;
: SEED 83C0 ! ;
: RANDOMIZE 8802 C@ DROP 0 BEGIN 1+ 8802 C@ 80 AND UNTIL SEED ;

 

How does RNDW , in particular, stack up with what you were using or what you're looking for?

 

...lee

Link to comment
Share on other sites

I'm probably a day late and a dollar short, and you are undoubtedly familiar with the following from TI FORTH:

 

: RNDW 83C0 DUP @ 6FE5 * 7AB9 + 5 SRC DUP ROT ! ;
: RND RNDW ABS SWAP MOD ;
: SEED 83C0 ! ;
: RANDOMIZE 8802 C@ DROP 0 BEGIN 1+ 8802 C@ 80 AND UNTIL SEED ;

 

How does RNDW , in particular, stack up with what you were using or what you're looking for?

 

...lee

 

I think the actual values it comes up with are fine for a pseudo random number generator. The only issue is performance. For games etc, one is often generating random numbers inside a loop, so performance is an issue. In the end I added an assembly RND routine to TF which so far seems to give good results, and is of course much faster. It seemed sensible, since I think a number of folks will want to try their hand at using TF for game development.

 

Regards

 

Mark

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...