Mikroelektronika MIKROE-724 データシート
224
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Expressions
An expression is a sequence of operators, operands and punctuators that returns a value.
The primary expressions include: literals, constants, variables and function calls. From them, using operators, more
complex expressions can be created. Formally, expressions are defined recursively: subexpressions can be nested
up to the limits of memory.
Expressions are evaluated according to certain conversion, grouping, associativity and precedence rules which
depend on the operators in use, presence of parentheses and data types of the operands. The precedence and asso-
ciativity of the operators are summarized in Operator Precedence and Associativity. The way operands and subex-
pressions are grouped does not necessarily specify the actual order in which they are evaluated by mikroBasic PRO
for dsPIC30/33 and PIC24.
Expression Evaluation
General Rule
Expression are evaluated according to the right side operands. Operations are done at higher operand level, with
signed operands taking precedence.
Example:
a as byte
b as word
c as integer
a * b ‘ word level
a * c ‘ integer level
b * c ‘ integer level
Left side exception
In arithmetic expression left side is considered in the following manner: If the left side size in bytes is greater than
higher operand size, then evaluation is done at one level above higher operand level (to get correct calculations).
Example:
a as longword
b as byte
a = b * 5 ‘ this is done at word level