Results 1 to 3 of 3

Thread: Random numbers

  1. #1
    ChimpFace9000
    Guest

    Post

    How do i get a random number?

  2. #2
    New Member
    Join Date
    Mar 2001
    Posts
    1

    Cool Heres a routine

    heres a routine

    .data

    RndInit dd 1110111011100111101110011001b

    .code

    Random proc
    ; Entry: al = size of random number
    ; Return: eax = random number, cl bits in size

    mov cl,al
    xor eax,eax
    mov bl,byte ptr RndInit
    and bl,1

    EVEN
    Gen_bit: ; make n bit numbers
    shl eax,1
    mov edx,RndInit ; Copy seed

    shr edx,9
    xor bl,dl

    shr edx,5
    xor bl,dl

    bt ebx,1 ; Copy bit 1 to carry flag
    rcr RndInit,1 ; Rotate seed right 1 bit

    setc bl ; Set bl TRUE if carry is set
    or al,bl
    dec cl
    jnz Gen_bit

    ret
    Random endp

  3. #3
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    http://www.agner.org/random/

    Has an assembler random number generator.
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width