I'm all in favour of LFSRs!
Thanks for sharing your code. Just a couple of things you're doing are not idiomatic in 6502 land.
You almost never need to compare with zero, because the Z flag is set by a load.
Here, I would probably use PHA and PLA, if tmp isn't needed inside the subroutine. (But in this case it is in fact the return value.)
But I think it will be more natural, faster, and shorter, to use carry as the return value.
Code: Select all
bcc not
...
lda #1
sta tmp
not:
rts
So we just need a SEC instead:
and now C is the return boolean. Which is nice, because we no longer need to initialise tmp.
So
Code: Select all
jsr begin
lda tmp
cmp #0
beq bit7
becomes
(probably!)
But also, as I think as noted upthread, your 8 calls to begin, with preamble and postamble, can be compressed into a loop. In which case begin need not be a subroutine, it can be placed inline.
I think it can be useful though, to start by writing code however it occurs to you, and get it debugged, and then to perform some transformations to improve it.