ascrnet Posted December 3, 2006 Share Posted December 3, 2006 hello I am aprenciendo to assembler of atari 8bits, but not like doing the following thing. 10 G=INT(RND(0)*6)+1 20 ? G:GOTO 10 I hope that greetings can help me!!! Quote Link to comment Share on other sites More sharing options...
danwinslow Posted December 3, 2006 Share Posted December 3, 2006 What don't you like about it? Quote Link to comment Share on other sites More sharing options...
ascrnet Posted December 3, 2006 Author Share Posted December 3, 2006 What don't you like about it? he is not that, the idea is to do the same but in assembler Quote Link to comment Share on other sites More sharing options...
Rybags Posted December 4, 2006 Share Posted December 4, 2006 $D20A is the hardware random generator which always returns a psuedo-random number from 0-255. The easiest way to get a "range" of values is to just AND out the bits you don't want. So, for 0-15, just LDA $D20A ; AND #$0F For a value 1-6, this is a quick/dirty way: GETRND LDA $D20A AND #$07 BEQ GETRND CMP #7 BEQ GETRND For different range (e.g. 30 to 50) it's best to just generate a number within the range 0 to (NUM2-NUM1) i.e. 0 to 20, then just CLC ; ADC #NUM1 I believe Atari BASIC also uses $D20A - and just discards any values which aren't valid BCD digits. 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.