User`s manual
- If one operand is byte and another is word, byte is converted in
word.
- If one operand is short and another is integer, short is converted to
integer.
- If one operand is short and another is longint, short is converted to
longint.
- If one operand is integer and another is longint, integer is converted to
longint.
4. After the first expression is decomposed to simpler ones, each of these simpler
ones is evaluated abiding the rules presented here.
Expression
a + b + c is decomposed like this:
First evaluate a + b and get (value of a + b)
This gives us another simple expression
(value of a + b) + c
Let's assume a and b are bytes and c is word, with values:
a = 23
b = 34
c = 1000
Compiler first calculates value of a + b and assumes that the result is byte:
a + b gives 57.
As c is of word type, result of adding
a + b is casted to word and then added to c:
57 + c is 1057.
Signed and unsigned numbers cannot be combined using arithmetical and logical
operators. Rules presented above are not valid when assigning expression result to
variable.
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
70
mikroBASIC
MikroElektronika: Development tools - Books - Compilers
making it simple...
page