; generates an 8 bit pseudo-random number which is returned in Acc.
; one byte of memory must be available for rand8reg
ORG 0H
rand8reg EQU 40H ;one byte
rand8: MOV A, rand8reg
JNZ rand8b
CPL A
MOV rand8reg, A
rand8b: ANL A, #10111000b
MOV C, P
MOV A, rand8reg
RLC A
MOV rand8reg, A
RET
END
Related topics:
8051 Program - 16bit random number generator | 8051 Program - bit shifting | 8051 Program - count external interrupt | 8051 Program - frequency measurement | 8051 Program - led rotation pattern | 8051 Program - memory subroutines | 8051 Program - math subroutines | 8051 Program - conversion subroutines
List of topics: 8051
No comments:
Post a Comment