The code runs as expected. I would like to find the problem, though. Things like that usually come back to bite me eventually. I suspect that I'm equating a bit variable with a byte

That is the trouble with the bigger chips - there are so many places for bad code to hide!