That's useful information Phil and Stephen!
Assuming that DDRB has been left at the default value of &0F,
It has, nothing in the code to that point has changed DDRB.
the top four bits are inputs and it doesn't matter what you write to them
I will move on and consider it an oversight by the original programmer or an artefact leftover from something else he tried to do. Thank you for the confirmation.
so you need to do this within a section of code with interrupts disabled.
The part I quoted in the original post is sandwiched between a SEI / CLI to disable the maskable interrupts. So I think it's doing the right thing.
Appreciate all the fast responses from everyone on this thread. Every day is an education