View Single Post
  #1   Spotlight this post!  
Unread 21-04-2008, 22:55
Los Frijoles's Avatar
Los Frijoles Los Frijoles is offline
Stormin' Mormon
AKA: Kevin Cuzner
FRC #2062 (C.O.R.E.)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Waukesha, WI
Posts: 27
Los Frijoles has a spectacular aura aboutLos Frijoles has a spectacular aura about
Send a message via AIM to Los Frijoles
Psuedorandom numbers

Well I have been studying psuedorandom sequences for Microchip microcontrollers based on seeds and so far the fastest I have found is thusly from mondo technology:
Code:
chop    movf    val1,w     ;get the 1st
        addwf   val2,w     ;add the 2nd
        movwf   val2       ;store the 2nd
        addwf   val3,w     ;add the 3rd & store
        movwf   val3       ;back in 3rd
        addwf   val1       ;add back to 1st
        swapf   val1       ;swap nibbles
        movf    val1,w     ;return one byte
        ret
It looks to be 10 instruction cycles long. However, I would like to see some other methods as I have found that this particular algorithm tends to repeat numbers after a short while with only a 24-bit seed. Does anyone else know of some psuedorandom sequences (C, ASM, or Psuedocode please)?
__________________
Community Of Robotic Engineers 2062





Blender totally pwns 3DS Max...

My life is here and here.

Cuznersoft Hardware and Software Development

Last edited by Los Frijoles : 21-04-2008 at 22:55. Reason: Citing my sources...