beautypg.com

Dbrnz (decrement and branch if not zero) – Echelon Neuron User Manual

Page 91

background image

DBRNZ (Decrement and Branch If Not Zero)

The DBRNZ instruction performs two functions: it decrements the unsigned 8-

bit value on the top of the return stack and performs a conditional branch. The

DBRNZ instruction uses the indirect addressing mode for the comparison and

the relative addressing mode for the branch operation. If the result of the

decrement is not zero, the instruction branches to the destination indicated by

the displacement value, which must be in the range -126 to +129. If the value on

the top of the return stack becomes zero, the DBRNZ instruction drops the value

from the return stack and continues processing with the next instruction. TOS is

not affected by this instruction.
The displacement expression must resolve at link time to a value in the range -

128 to +127 (two less than the actual displacement because the displacement

calculation includes the size of the DBRNZ operation itself).
The Neuron Assembler also supports the use of a label for the displacement

expression; manual calculation of the displacement value is not required.
The DBRNZ instruction applies to Series 3100, 5000, and 6000 devices.

Syntax:
The DBRNZ instruction requires a single operand to specify the displacement:

DBRNZ displacement

Table 26 describes the attributes of the DBRNZ instruction.

Table 26. DBRNZ Instruction

Instruction

Hexadecimal

Opcode

Instruction

Size (Bytes)

CPU Cycles

Required

Affect on

Carry Flag

DBRNZ

70

2

5

None


Example:
The following example calls a function named do_it repeatedly, until the value n

on the return stack is zero. Thus, this example implements a do until loop

construct. This example assumes that the called function resides at a high

memory address or is a system function.

Example APEXP ; ( n -- )

poppush ; ( ) R(n)

loop_body ; ( ) R(n)

callf do_it ; ( ) R(n)

dbrnz loop_body ; ( ) R({n})

ret ; ( ) R( )

Neuron Assembly Language Reference

81