This is definitely a first draft and crude code, because I wanted to watch every step. There are obvious ways to shorten it. As written it has a repeat cycle of 14 (i.e., the 14th loop repeats the seed). That is, if counter runs to zero, it ends up with 0xAC (seed=DA, then B5, 6B, D6, AC... all in hex). No guarantee it actually meets the definition of an LFSR as given in Wikipedia for the Fibonacci type. That is what I am playing with right now for Sunday fun. It is written for an enhanced mid-range chip (16F1829), so there are instructions not available per se, but easily adapted to your chip.
Code:
org 0x0000
nop
bra Start
Start
clrf counter
clrf output
movlw 0xDA ;b'1101 1010'
movwf seed
Loop
movlw b'10101000' ;bits <7,5,3> used to xor seed
andwf seed,w
movwf taps ;taps has the seed's values at those bits
lslf seed,w ;sets or clears STATUS,0 w/ seed <bit7>
rrf output,f ;moves seed<7> value to output<7>
movlw b'10000000'
andwf taps,w
xorwf output,f
lslf taps,f
lslf taps,f
movlw 0x80
andwf taps,w
xorwf output,f
lslf taps,f
lslf taps,f
movlw 0x80
andwf taps,w
xorwf output,f
lslf output,f
rlf seed,f ;move xor'd result into seed<0>
; incf counter,f
incfsz counter,f
bra Loop
nop
end
In answer to your question of how to XOR single bits sequentially (as described in Wikipedia), I used rotates to create an 8-bit byte with only bit<7> set (or clear) and xor'd that with another similarly constructed byte.
The Wiki article is interesting, but I do not understand it yet: 1) Rather than using conventional bit numbering of 0..15, it uses 1..16; and 2) Which numbering system is used to determine whether the condition for a "primitive polynomial" are met? That is, taps in the example at 16,14,13, and 11 are setwise co-prime even if one uses conventional numbering of 15,13,12,and 10. However, using Wiki's numbering, taps at 15,13,11,and 5 would be co-prime, but using conventional numbering those become 14,12,10,and 4, which are not co-prime.
If someone sees an obvious error in the code, please let us know as that code is truly just a first draft.
EDIT: There seems to be an error(s) in the algorithm. Seed #'s of 1 and 2 don't repeat, and using the taps at 8,6,5,4 it gives a repeat unit of about 34 loops instead of the expected 255.