Expressions

The operands to instructions and directives are comprised of expressions. Expressions can be made up of numbers, identifiers, strings and operators.

Operators can be unary (one operand, e.g., not) or binary (two operands, e.g., +). The operators allowable in expressions are listed in the Table 1 table.

The usual rules governing the syntax of expressions apply.

The operators listed can all be freely combined in both constant and relocatable expressions. The linker permits relocation of complex expressions, so the results of expressions involving relocatable identifiers cannot be resolved until link time.

Table 1. Assembly Operators
Operator Purpose Example
* multiplication movlw 4*33,w
+ addition bra $+1
- subtraction DB 5-2
/ division movlw 100/4
= or eq equality IF inp eq 66
> or gt signed greater than IF inp > 40
>= or ge signed greater than or equal to IF inp ge 66
< or lt signed less than IF inp < 40
<= or le signed less than or equal to IF inp le 66
<> or ne signed not equal to IF inp <> 40
low low byte of operand movlw low(inp)
high high byte of operand movlw high(1008h)
highword high 16 bits of operand DW highword(inp)
mod modulus movlw 77mod4
& or and bitwise AND clrf inp&0ffh
^ bitwise XOR (exclusive or) movf inp^80,w
| bitwise OR movf inp|1,w
not bitwise complement movlw not 055h,w
<< or shl shift left DB inp>>8
>> or shr shift right movlw inp shr 2,w
rol rotate left DB inp rol 1
ror rotate right DB inp ror 1
float24 24-bit version of real operand DW float24(3.3)
nul tests if macro argument is null