Chapter 8 Writing Source Statements

8.7.1Operators

There are three types of operators.

Arithmetic operators

Shift operators

Logical operators

Arithmetic operators

Arithmetic operators perform the four standard arithmetic calculations.

 

Operator

 

Meaning

 

 

 

 

 

 

 

 

 

*

 

Multiplication

 

 

 

/

 

Division

 

 

 

%

 

Modulo operator (remainder)

 

 

+

 

Addition

 

 

 

-

 

Subtraction

 

 

 

+

 

Unary plus (positive)

 

 

 

~

 

Unary minus (negative)

 

 

Formats:

Example:

 

 

 

operand1

*

 

operand2

123 * LABEL

operand1

/

 

operand2

123 / 10

 

operand1

%

 

operand2

COUNT % 4

operand1

+

 

operand2

SATRT + 0x10

operand1

operand2

STACK – 16

+ operand

 

 

 

+SIGN

~operand

 

 

 

-SIGN

Shift operators

The shift operators shift to the left or right in bit units.

Operator

Meaning

>>Logical right shift

<< Logical left shift

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

Page 150
Image 150
Panasonic MN1030 user manual Operators, Arithmetic operators, Shift operators, Operator Meaning