How programming Random Algorithm

Status
Not open for further replies.

J_expoler2

Member level 4
Joined
May 10, 2003
Messages
77
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
619
Hi.
any one can advice randomalgorithm on assembly 8051 and AVR
thanks
 

formula: seed = seed * 1021 + 41
pseudo random: cycle = 65536
51's assembly code:
Code:
Random:			;R6,R7=Seed.H,Seed.L
	CLR     C
	CLR     A
	SUBB    A,R7
	MOV     R5,A
	MOV     A,R7
	SUBB    A,R6
	MOV     R4,A	;*255
	MOV     A,R5
	ADD     A,R5
	MOV     R5,A
	MOV     A,R4
	ADDC    A,R4
	MOV     R4,A
	MOV     A,R5
	ADD     A,R5
	MOV     R5,A
	MOV     A,R4
	ADDC    A,R4
	MOV     R4,A
	MOV     A,R5
	ADD     A,R7
	MOV     R7,A
	MOV     A,R4
	ADDC    A,R6
	MOV     R6,A	;*1021
	MOV     A,#41
	ADD     A,R7
	MOV     R7,A
	CLR     A
	ADDC    A,R6
	MOV     R6,A
	RET
FYR
 

Hi J_expoler2,

random sequences are generated by a PN-generator (PN = pseudo noise).
Such a generator is made of a shift-register an one or more EXOR-gates.
This can be built easily in hardware (CPLD) or programmed in a uC. When
you search the internet wit PN, pseudo noise you will find some examples.

Bye
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…