Your place is saved automatically on this browser.
Normally, the Program Counter moves forward to the next instruction. A branch instruction changes that path. For example, a conditional relative jump can say: ‘If Z is clear, continue execution at the label not_equal; otherwise carry on with the next line.’
The common conditional forms of JR are JR Z,label, JR NZ,label, JR C,label and JR NC,label. Z means Zero set, NZ means Zero not set, C means Carry set and NC means Carry not set.
There is also an unconditional JR label, which always jumps. None of these JR instructions updates the flags, so the state established by the comparison remains available unless another instruction changes it.
Relative versus absolute jumps
JR is a relative jump. The machine code holds a signed offset measured from the address after the two-byte instruction. A normal JR can reach from −128 to +127 bytes relative to that point. The assembler computes the offset from the label. You do not need to calculate it manually for these exercises.
JP label is an absolute jump to a 16-bit address. It reaches farther than JR and offers additional conditions. We will normally prefer a readable JR for short local decisions, then use an appropriate JP when the target is outside relative-jump range or the design calls for it. If Odin reports a jump out of range, do not change random numbers; inspect the target and consider JP.
Flow through a decision
A condition chooses which instructions execute, not which instructions assemble. Both paths are present in the machine-code programme; the CPU follows only the selected path at run time.
