For the Sub/Compare with carry, the old Z flag is also used to AND the newZ: newZ = (result==0) & oldZ