3.5 Operators

The operators defined by the PIC Assembler can be used in most expressions. Unlike those in MPASM, the PIC Assembler operators have no operator precedence and they all have left-to-right associativity. You may need to use parentheses when migrating complex expressions to ensure they are evaluated as they would have been in MPASM.

The MPASM operators and their PIC Assembler equivalents are tabulated below.

Table 3-7. Equivalent Operators
MPASM OperatorPurposePIC Assembler Equivalent
$Current/Return program counter$
(Left parenthesis(
)Right parenthesis)
!Logical compliment (NOT)No equivalent
-Negation (2's compliment)-
~Complementnot
lowLow address bytelow
highHigh address bytehigh
upperUpper address bytelow highword
*Multiplication*
/Division/
%Modulusmod
+Addition+
-Subtraction-
<<Left shift<< or shl
>>Right shift>> or shr
>=Greater than or equal>= or ge
>Greater than> or gt
<Less than< or lt
<=Less than or equal<= or le
==Equality= or eq
!=Inequality<> or ne
&Bitwise AND& or and
^Bitwise XOR^
|Bitwise OR|
&&Logical ANDNo equivalent
||Logical ORNo equivalent
=AssignmentNo equivalent
+=Assignment additionNo equivalent
-=Assignment subtractionNo equivalent
*=Assignment multiplicationNo equivalent
/=Assignment divisionNo equivalent
%=Assignment modulusNo equivalent
<<=Assignment left shiftNo equivalent
>>=Assignment right shiftNo equivalent
&=Assignment logical ANDNo equivalent
|=Assignment logical ORNo equivalent
^=Assignment logical XORNo equivalent
++IncrementNo equivalent
--DecrementNo equivalent