beautypg.com

Character constants, Operator precedence, Character constants operator precedence – Zilog ZUSBOPTS User Manual

Page 251: Table 20

background image

UM017105-0511

Expressions

Zilog Developer Studio II – ZNEO™

User Manual

223

indicated by the absence of a sign. Negative numbers are indicated by a minus sign (

-

)

preceding the number. Underscores (_) can be inserted between octal digits to improve
readability. For example:

1234o ; octal number

-1234o ; negative octal number

1_234o; octal number with underscore

Character Constants

A single printable ASCII character enclosed by single quotes (

'

) can be used to represent

an ASCII value. This value can be used as an operand value. For example:

'A' ; ASCII code for "A"

'3' ; ASCII code for "3"

Operator Precedence

Table 20 shows the operator precedence in descending order, with operators of equal pre-
cedence on the same line. Operators of equal precedence are evaluated left to right. Paren-
theses can be used to alter the order of evaluation.

Shift Left (<<) and OR (|) have the same operator precedence and are evaluated from left
to right. If you must alter the order of evaluation, add parentheses to ensure the appropriate
operator precedence. For example:

ld r0, # 1<<2 | 1<<2 | 1<<1

The constant expression in the preceding instruction evaluates to 2A H.

If you want to perform the Shift Left operations before the OR operation, use parentheses
as follows:

ld r0, #(1<<2)|(1<<2)|(1<<1)

The modified constant expression evaluates to 6 H.

Table 20. Operator Precedence

Level 1

()

Level 2

~

unary- !

low

Level 3

**

*

/

%

Level 4

+

-

&

|

^

>>

<<

Level 5

<

>

<=

>=

==

!=

This manual is related to the following products: