Mnemonics

JR

Jump Group
Expansion:
Jump Relative
Usage:
jr [f,],{label|??}

Jump relative takes 1 less byte than the JP (JumP) operation but it is slower. It can jump within a range of -128 to +127 bytes from its current relative position.

Z80.CPU instructions
Instruction Description Opcode
JR label Jump relative with label. Our assembler will work this out for us. 18 {??}
JR ±bytes Jump relative in bytes from current line 18 {??}
JR Z, {label|??} Jump relative if Zero flag (Z) is set. 28 {??}
JR NZ, {label|??} Jump relative if Zero flag (Z) is not set. 20 {??}
JR C, {label|??} Jump relative if Carry flag (C) is set. 38 {??}
JR NC, {label|??} Jump relative if Carry flag (C) is not set. 30 {??}

Note: The jr instruction does not support the p, m, pe, or po conditions due to its shorter instruction encoding and intended use for short-range jumps.

Example

; Example ld a, 5 ; move the value 5 to reg A loop: dec a ; decrement a jr nz, loop ; if non-zero flag then jump releative to loop ; (our assembler will work out the relative byte ; count for the 'loop' label) ret

See also