jr
Jump relative
Jumps to a target up to 128 bytes away, either always or only when a flag condition is met.
12/7 cycles: 12 when it jumps, 7 when it does not
Used in
- jp, jr and the conditionsZ80 assembly
- Loops and djnzZ80 assembly
- Arrays, strings and ixZ80 assembly
- call, ret and passing valuesZ80 assembly
- Ports: in and outZ80 assembly
- The screen, keyboard and mouse through portsZ80 assembly
- Interrupts: im, ei, di and haltZ80 assembly
- The bigger of two numbersZ80 assembly
- The largest elementZ80 assembly
- Length of a stringZ80 assembly
SZHP/VNC ––––––
- Changes no flag
Forms
jr2 bytes · 12 cyclesThe signed value
offsetis added to PC. The jump is measured from the start of the instruction opcode.-
If the condition
ccis true, the signed valueoffsetis added to PC. The jump is measured from the start of the instruction opcode.
Operands
offset- A relative-jump target, written as a label or address. The assembler calculates the displacement,
-128to127, and reports an error if the target is out of range. More cc- A flag condition:
nz(zero flag clear,Z = 0),z(zero flag set,Z = 1),nc(carry flag clear,C = 0) orc(carry flag set,C = 1). Herectests the carry flag; it does not name thecregister. More
.org 0x8000
jr target
target: halt