Willsy Posted August 18, 2011 Share Posted August 18, 2011 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 Quote Link to comment Share on other sites More sharing options...
lucien2 Posted August 18, 2011 Share Posted August 18, 2011 http://www.atariage.com/forums/topic/177268-8x8-random-call-char-junk/page__view__findpost__p__2211367 Quote Link to comment Share on other sites More sharing options...
Willsy Posted August 18, 2011 Author Share Posted August 18, 2011 Thanks! Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted August 18, 2011 Share Posted August 18, 2011 Compact routine here :- http://www.atariage.com/forums/topic/163646-not-prime/page__view__findpost__p__2020385 Quote Link to comment Share on other sites More sharing options...
Willsy Posted August 18, 2011 Author Share Posted August 18, 2011 Compact routine here :- http://www.atariage.com/forums/topic/163646-not-prime/page__view__findpost__p__2020385 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 Quote Link to comment Share on other sites More sharing options...
+retroclouds Posted August 18, 2011 Share Posted August 18, 2011 Compact routine here :- http://www.atariage.com/forums/topic/163646-not-prime/page__view__findpost__p__2020385 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. Quote Link to comment Share on other sites More sharing options...
Willsy Posted August 18, 2011 Author Share Posted August 18, 2011 Compact routine here :- http://www.atariage.com/forums/topic/163646-not-prime/page__view__findpost__p__2020385 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. Quote Link to comment Share on other sites More sharing options...
+InsaneMultitasker Posted August 18, 2011 Share Posted August 18, 2011 You reminded me of this gem... http://dilbert.com/strips/comic/2001-10-25/ 2 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted September 8, 2011 Share Posted September 8, 2011 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 Quote Link to comment Share on other sites More sharing options...
Willsy Posted September 8, 2011 Author Share Posted September 8, 2011 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.