Here is a story of a man-made software issue which really had me stumped.
I’ll pose it as a question , just for fun. The answer to follow in the near future after a few interested readers have had a go, although I’m guessing a number of you may spot this quite easily.
The symptom:My 6502 SBC has a flashing led routine for testing. It would flash a few leds at a rate of about 1 flash per second, well sometimes. Now and again, it would flash at high speed. I’m using a 1Mhz oscillator.
This is the delay routine:
Code:
delay:
LDX $FF
loopx: LDY $FF
loopy: DEY
BNE loopy
DEX
BNE loopx
RTS
It is a nested loop routine.
So why did it sometimes produce a correct delay and sometimes a minimal delay?
But wait, there's more:
I also had an 8251 serial comms chip which worked perfectly in another bit of code. Then a few days later it decided not to work.
The part of the code that was blocking things was isolated to this section of code:
Code:
loop1:
LDA CONFIG8251
AND #$01
BEQ loop1 ; if not ready
It reads a status bit (bit 0) and if the bit is '0', then go back and keep looping until it goes high.
The two problems are related - have you spotted it?
regards
Russell