III.4 Expressions

Arithmetic expressions are composed of operands, operators and parentheses. Operands may be user-defined symbols, constants or special assembler symbols. All operands are treated as unsigned 16-bit numbers. Special assembler symbols, that can be used as operands are:

AR0, ... , AR7 direct addresses of registers R0 thru R7
$ the location counter of the currently active segment (start address of the current assembler statement)

The following operators are implemented:

Unary Operators
Operator Operation Definition
+ identity +x = x
- two's complement -x = 0-x
NOT one's complementNOT x = FFFFH-x
HIGHhigh order byte  
LOW low order byte  

Binary Operators
Operator Operation Result
+ unsigned addition  
- unsigned subtraction
* unsigned multiplication
/ unsigned division
MOD unsigned remainder
SHL logical shift left
SHR logical shift right
AND logical and
OR logical or
XOR exclusive or
. bit operator used for bit-adressable locations
EQ   or   = equal to 0 if FALSE,
FFFFH if TRUE
NE   or   <>not equal to
LT   or   < less than
LE   or   <= less or equal than
GT   or   > greater than
GE   or   >= greater or equal than

Operators that are no special characters but keywords as SHR or AND must be separated from their operands by at least one blank or tab. In general expressions are evaluated from left to right according to operator precedence, which may be overridden by parentheses. Parentheses may be nested to any level.
Expressions always evaluate to unsigned 16-bit numbers, while overflows are ignored. When an expression result is to be assigned to an 8-bit quantity, the high byte must be either 00 or FF.

Operator Precedence
Operator(s) Type Precedence
  (   )     highest
  +   -   NOT   HIGH   LOW   unary  
  .    
  *   /   MOD  
  SHL   SHR  
  +   -   binary
  EQ   =   NE   <>   LT   <   LE   <=   GT   >   GE   >=    
  AND  
  OR   XOR   lowest


Example:

The expression
        P1.((87+3)/10 AND -1 SHR 0DH)
will evaluate to 91H.