djnz

Decrement B and jump if not zero

Decrements B and jumps to the target when B is not zero.

2 bytes · 13/8 cycles13 cycles when it jumps, 8 when it does not

SZHP/VNC ––––––
  • Changes no flag

Forms

  • djnz

    The B register is decremented, and if not zero, the signed value offset is 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, -128 to 127, and reports an error if the target is out of range. More
        .org 0x8000
        ld b, 3
loop:   djnz loop
        halt