8 Bit Random Numbers

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

Reply to
Bill Bowden
Loading thread data ...

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.

Reply to
Nobody

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

Reply to
Bill Bowden

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.