<< Previous | Next >>

> DWJNZ label Decrement Word and Jump if Not Zero Rabbit 4000 Instruction

> Opcode | Instruction | Clocks | Operation
> ED 10 e | DWNJZ label DWJNZ mn1 | 7 (2,2,2,1) | BC = BC - 1 if {BC != 0} PC = PC2 + e

> 1 The 16-bit constant mn is the destination logical address of the jump. 2 The value of PC after the instruction fetch.

> Flags | ALTD | IOI/IOE
> S | Z | L/V | C | F | R | SP | S | D
> - | - | - | - |  | · |  |  |

> #### Description

> This instruction controls program flow by allowing conditional jumps to specified locations.

> First, BC is decremented. If BC does not equal zero, the instruction transfers control to the specified address. The address is specified by a label or logical address. The assembler translates the label or logical address "mn" to an 8-bit signed displacement value "e".

> The displacement value "e" is relative to the address of the first byte of the instruction following DWJNZ. This fact is because the processor calculates the new PC value after it increments the PC for the instruction fetch of DWJNZ.

> If BC does equal zero, PC is incremented normally.

> Note that the relative jump has a limited range of [-128, 127] from the address of the first byte of the instruction following the DWJNZ instruction.

<< Previous | Next >>