I'm having a bit of brain freeze, probably a caffeine shortage...
I'm looking at a piece of Z80 assembler that detects the loss of a timer interrupt. OUTERCOUNT is zeroed once per second in the timer interrupt and is a 16 bit variable.
LD HL,(OUTERCOUNT) INC HL LD (OUTERCOUNT),HL LD A,L OR H JP Z,ERROR
This code called in the main system scheduler loop and so runs continuously (except when interrupted). As far as I can tell then the ERROR label is jumped to when OUTERCOUNT is zero i.e. the high byte ORed with the low byte is zero.
That can't be right because this is supposed to be a watchdog allowing the OUTERCOUNT to count up to a certian value before tripping. What is going on here?