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.
MPASM Operator | Purpose | PIC Assembler Equivalent |
---|---|---|
$ | Current/Return program counter | $ |
( | Left parenthesis | ( |
) | Right parenthesis | ) |
! | Logical compliment (NOT) | No equivalent |
- | Negation (2's compliment) | - |
~ | Complement | not |
low | Low address byte | low |
high | High address byte | high |
upper | Upper address byte | low highword |
* | Multiplication | * |
/ | Division | / |
% | Modulus | mod |
+ | 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 AND | No equivalent |
|| | Logical OR | No equivalent |
= | Assignment | No equivalent |
+= | Assignment addition | No equivalent |
-= | Assignment subtraction | No equivalent |
*= | Assignment multiplication | No equivalent |
/= | Assignment division | No equivalent |
%= | Assignment modulus | No equivalent |
<<= | Assignment left shift | No equivalent |
>>= | Assignment right shift | No equivalent |
&= | Assignment logical AND | No equivalent |
|= | Assignment logical OR | No equivalent |
^= | Assignment logical XOR | No equivalent |
++ | Increment | No equivalent |
-- | Decrement | No equivalent |