RandomRange help

[b][red]This message was edited by ajtr211 at 2002-12-14 8:44:31[/red][/b][hr]
[b][red]This message was edited by ajtr211 at 2002-12-14 8:42:29[/red][/b][hr]

50 Random integers between the range of
-20 and +20


  • well,the first thing is to write a random-number generator.there are many possible ways to do this,but my prefered way is to read a value from the timer (port 40h) and to alter it with an other value from a variable.example in pseudocode (no,i wont do your homework :) ):

    a = port[40h]
    randnumber = ((randseed xor a) - a) rol 5

    now you could use a modulo-division to get a value between 0 and 20:

    randseed = randseed mod 21

    then you have to convert the binary number you should have in memory or a x86-register to a ASCII string.you could do this in a loop by divide your number by 0ah.the modulo of this is your digit,simply add 30h and you have the ascii-code.write this numbers to a string and output it.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion