beautypg.com

Br (branch) – Echelon Neuron User Manual

Page 80

background image

BR (Branch)

The BR instruction performs an unconditional branch. The BR instruction uses

the relative addressing mode. The BR instruction branches forward or backward

with a signed relative displacement of -126 to +129 bytes. 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 BR 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.
See also BRF (Branch Far) for a longer unconditional branch and SBR (Short

Branch) for a shorter unconditional forward branch.
The BR instruction applies to Series 3100, 5000, and 6000 devices.

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

label:

BR displacement

BR label

Table 16 describes the attributes of the BR instruction.

Table 16. BR Instruction

Instruction

Hexadecimal

Opcode

Instruction

Size (Bytes)

CPU Cycles

Required

Affect on

Carry Flag

BR

71

2

2

None


Example:
The following example shows two functions that share a common set of code. The

BR instruction branches unconditionally from the end of one function to the

Common label to run the common code.

Sub_B ... ; subroutine B

br Common

Sub_A ... ; subroutine A

Common ... ; common code

ret ; return to caller

70

Neuron Assembly Language Instruction Statements