Jump to content



0

Assembly RND routine?


9 replies to this topic

#1 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Thu Aug 18, 2011 3:57 AM

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

#2 lucien2 OFFLINE  

lucien2

    Chopper Commander

  • 160 posts
  • Location:Switzerland

Posted Thu Aug 18, 2011 4:06 AM

http://www.atariage....ost__p__2211367

#3 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Thu Aug 18, 2011 4:35 AM

Thanks! :)

#4 GroovyBee OFFLINE  

GroovyBee

    7800 Developer

  • 5,782 posts
  • Busy bee!
  • Location:North, England

Posted Thu Aug 18, 2011 5:00 AM

Compact routine here :-

http://www.atariage....ost__p__2020385

#5 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Thu Aug 18, 2011 6:32 AM

View PostGroovyBee, on Thu Aug 18, 2011 5:00 AM, said:


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

#6 retroclouds OFFLINE  

retroclouds

    Stargunner

  • 1,096 posts
  • Location:Germany

Posted Thu Aug 18, 2011 7:53 AM

View PostWillsy, on Thu Aug 18, 2011 6:32 AM, said:

View PostGroovyBee, on Thu Aug 18, 2011 5:00 AM, said:


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.

#7 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Thu Aug 18, 2011 8:25 AM

View Postretroclouds, on Thu Aug 18, 2011 7:53 AM, said:

View PostWillsy, on Thu Aug 18, 2011 6:32 AM, said:

View PostGroovyBee, on Thu Aug 18, 2011 5:00 AM, said:


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

#8 InsaneMultitasker OFFLINE  

InsaneMultitasker

    Chopper Commander

  • 210 posts

Posted Thu Aug 18, 2011 8:31 AM

You reminded me of this gem...

http://dilbert.com/s...mic/2001-10-25/

#9 Lee Stewart OFFLINE  

Lee Stewart

    Chopper Commander

  • 175 posts

Posted Wed Sep 7, 2011 8:50 PM

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

#10 Willsy OFFLINE  

Willsy

    Dragonstomper

  • 765 posts
  • Location:Uzbekistan (no, really!)

Posted Thu Sep 8, 2011 6:59 AM

View PostLee Stewart, on Wed Sep 7, 2011 8:50 PM, said:

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




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users