Your place is saved automatically on this browser.
The label exists, but the wrong line executes
First look for an accidental fall-through. If both the ‘yes’ path and ‘no’ path of a decision are executed, a missing JR done may be the explanation. Also check whether the comparison was performed before the conditional jump and whether another instruction changed the tested flag in between.
The loop repeats too many times
Check B before DJNZ. An initial B of zero means 256 iterations for an ordinary loop body, not zero. Also ensure the loop body does not unexpectedly modify B, because that would interfere with the counter.
The subroutine does not return
Check the exact route into it. A JR to a routine is not a CALL, and its RET will not have the expected saved return address. Check every CALL path has an appropriate RET, and do not delete or bypass POP instructions after a PUSH. If the computer becomes unresponsive, reboot if necessary, reload the last saved source, correct one issue and reassemble before running again.
A register unexpectedly changes
Find every instruction in the called routine which writes that register, and verify its documentation block. The routine may need to preserve it with a matching PUSH/POP pair, or the caller’s assumptions may be wrong. Documenting ‘Changes: AF’ is more useful than relying on a convention you never stated.
The flags appear inconsistent
Identify the last flag-modifying instruction. A register load may change A without updating F. A comparison may update F without changing A. DJNZ does not alter F. A conditional branch consults the flags but does not update them. These rules often explain apparently contradictory register displays.
Odin reports an error
Read the first error rather than guessing. Check label names on both sides of a branch, the instruction’s operand syntax, commas, hexadecimal $ signs, and missing or extra lines. Confirm you are editing the file you intended. Fix one issue, use A again, and only run after a successful assembly.
Instruction quick-reference — keep beside Odin
The same small instruction family has appeared repeatedly. This table is designed for looking things up while working, not for memorisation. “Does not change F” means the instruction does not recompute the arithmetic flags; an exceptional operation such as POP AF can restore an earlier F value from memory.
Conditions you will see often: Z = Zero set; NZ = Zero clear; C = Carry set; NC = Carry clear. A condition belongs to the immediately preceding meaningful flag-setting operation, not necessarily to the instruction immediately before it. Z80N adds instructions later, but everything in this table works on the original Z80 too.
