8 Bit Random Numbers

Jan 28, 2009 62 Replies

Yes, but there is no tap bit at the lowest bit using B8. Therefore, the incoming bit is always "0" and never gets flipped. Maybe the xor word should have the lowest bit set and B8 should be changed to "1D" ?

-Bill

B8 is for right shift, i.e. 0x80 is the incoming bit. For left shift, use 1D.

But, you're right that the incoming bit must be set in the tap word, otherwise half of the states will never occur. Or you could use a rotate and leave the incoming bit clear (38 or 1C). Either way, the incoming and outgoing bits will always be equal.

incoming

Yes, that works using "1D" as the tap word and clearing the carry bit before the next shift left, so the incoming bit is always "0" and gets flipped if the outgoing bit was "1". I get all 255 states.

Loop:

RLF RANDOM,f ; Roll left BTFSC STATUS,0 ; Skip if flag is clear XORWF RANDOM,f ; xor if flag is set BCF STATUS,0 ; Clear carry bit GOTO Loop

-Bill

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required