Chapter 8 Writing Source Statements

8.7.2Expression Evaluation

There are seven levels of operator precedence. The order of precedence can be changed using parentheses ( ). Operators with the same precedence are evaluated in order from left to right.

Precedence

Operator

Description

 

 

 

 

Highest

~

+ -

Unary negation, unary plus, unary minus

 

*

/

%

Multiplication, division, remainder

 

 

 

+

-

Addition, subtraction

 

 

 

<<

>>

Left shift, right shift

 

 

 

 

&

Logical AND

 

 

^

 

Exclusive OR

Lowest

 

 

 

 

 

 

Logical OR

An example of operator is shown below.

c1

equ

10

c2

equ

0b01101110

_CODE

section

CODE, PUBLIC, 1

data1

dc

c1/3*(3+4)

data2

dc

c1%3*(3+4)

data3

dc

-c2

data4

dc

~c2

data5

dc

c2>>2

data6

dc

c1<<2

data7

dc

main>>2

data8

dc

c2>>2^0b00001111)>>2

data9

dc

(c2&0b00001111)

data10

dc

c20b00001111

 

org

0x100

main

mov

c2 & 0b00001111, D0

 

end

 

An asterisk * is used as both the self-reference address symbol and the multiplication operator, so take care in its use. The expression *** will be multiplication of the self-reference address symbol by itself.

140 Expressions

Page 152
Image 152
Panasonic MN1030 user manual Expression Evaluation, Precedence Operator Description, Equ 0b01101110