Search code examples
assemblyinstruction-setz80

Equivalents to Z80 DJNZ instruction on other architectures?


First a little background. The z80 CPU has an instruction called DJNZ which can be used in a similar manner as a for loop. Basically DJNZ decrements the B register and jumps to a label if not zero. For example:

    ld      b,96                    ; erase all of the line
disp_version_erase_loop:
    call    _vputblank              ; erase pixels at cursor (uses b reg)
    djnz    disp_version_erase_loop ; loop 

Of course you can do the same thing using regular comparison and jump instructions, but often it is handy to use the single instruction.

With that out of the way, my question is, do other CPU architectures include a similar control instruction?


Solution

  • That was a fairly common instruction on machines of that era, and occurs in many other places as well.

    And so on