beautypg.com

Constant expressions – Echelon Neuron User Manual

Page 23

background image

Table 5. Special Operator Functions

Function

Description

LB

Extracts the low byte of the expression

HB

Extracts the high byte of the expression

(logical shift right by eight bits)

NEAR

Offset value for the RAMNEAR area

(only computable at link time)

Example:
The following example demonstrates the use of the @NEAR expression. The

example implements a one-byte variable in the RAMNEAR segment, and a

function named Example that increments this global variable.

; open RAMNEAR segment, declare one byte

; uninitialized variable

SEG RAMNEAR

ORG

myVariable EXPORT

RES 1

; The Example routine takes no arguments and produces

; no results, but increments the global variable

SEG CODE

ORG

pNear EQU 1

Example APEXP ; ( -- )

push [pNear][@NEAR(myVariable)]

inc

pop [pNear][@NEAR(myVariable)]

ret ; return to caller

Constant Expressions

A constant expression is a general expression that is computable at assembly time

and has a constant value in an appropriate range for the specified instruction or

directive.
An expression that is not constant is one that is computable only at link time or

that has a variable value at runtime. Such symbols must be designated as

imported symbols.
Important: An expression that uses either the * or @NEAR special operator

cannot be a constant expression.
When using negative constants, or expressions that yield negative results, in a

byte context, you must use the @LB special operator (or specify the --autotrunc

[-a] command-line switch) to obtain a one-byte value for the value. For example,

use PUSH #@LB(-1) instead of PUSH #-1 (the latter will fail assembly).

Neuron Assembly Language Reference

13