beautypg.com

Brneq (branch if not equal) – Echelon Neuron User Manual

Page 84

background image

BRNEQ (Branch If Not Equal)

The BRNEQ instruction compares TOS with a specified number and performs a

conditional branch if they are not equal. The BRNEQ instruction uses the

relative addressing mode for the branch destination and the immediate

addressing mode for the test condition. The BRNEQ instruction compares TOS

to a constant expression. The expression number must resolve at link time to a

constant in the range -128 to +127.
After the comparison, the BRNEQ instruction branches forward or backward

with a signed relative displacement of -125 to +130 bytes if TOS is not equal to

number; otherwise, program operation continues with the next instruction. The

displacement expression must resolve at link time to a value in the range -128 to

+127 (three less than the actual displacement because the displacement

calculation includes the size of the BRNEQ 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 BRNEQ instruction applies to Series 3100, 5000, and 6000 devices.

Syntax:
The BRNEQ instruction requires two operands: one to specify the number for

comparison and one to specify the displacement or label:

BRNEQ #number, displacement

BRNEQ #number, label

The number sign or hash (#) is required to specify the immediate value.
Table 20 describes the attributes of the BRNEQ instruction.

Table 20. BRNEQ Instruction

Instruction

Hexadecimal

Opcode

Instruction

Size (Bytes)

CPU Cycles

Required

Affect on

Carry Flag

BRNEQ

76

3

4

(if branch is

taken)
6

(if branch is not

taken)

None


Example:
The following example tests the argument in TOS for the ASCII codes 65 (for ‘A’),

66 (for ‘B’), and 67 (for ‘C’), and calls a related function for each. The example

shows one possible assembly implementation of a C-language switch/case

construct.

Example APEXP ; (argument -- )

74

Neuron Assembly Language Instruction Statements