Chapter 8 Writing Source Statements
8.7.1
Operators
There are three types of operators.
•
Arithmetic operators
•
Shift operators
•
Logical operators
Arithmetic operators
Arithmetic operators perform the four standard arithmetic calculations.
Formats:
operand1
operand1
operand1
operand1
operand1
+ operand
~operand
Shift operators
The shift operators shift to the left or right in bit units.
Formats:
operand>>countADDRESS >> 3 3-bit right shift
operand<<countADDRESS << 4 4-bit left shift
Binary 0 (zero) will be shifted in. Shifted out bits will be lost.
138 Expressions
Operator
*
Multiplication
/
Division
%
Modulo operator (remainder)
+
Addition
-
Subtraction
+
Unary plus (positive)
~
Unary minus (negative)
Example:
*
/
%
+
–
Operator
>>
Logical right shift
<<
Logical left shift
Meaning
operand2
123 * LABEL
operand2
123 / 10
operand2
COUNT % 4
operand2
SATRT + 0x10
operand2
STACK – 16
+SIGN
-SIGN
Meaning