User`s manual

mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
MikroElektronika:
Development
tools
-
Books
-
Compilers
mikroBASIC
making it simple...
65
page
mikroBasic provides automatic type conversion every time an assignment is per-
formed. But it does not allow assigning signed data to unsigned and vice versa,
because there is a significant risk of losing information.
Implicit conversion takes place when assignment is performed:
between byte and word
between short, integer, and longint
Destination will store the correct value only if it can properly represent the result
of expression (that is, if the result fits in destination range).
Feel free to use operands of any size under the defined rules, but keep in mind that
the PIC is optimized to work with bytes. Every operation involving more complex
data types (word, integer or longint) will take more run time and more memory. So
for the best possible results, use as small destinations and operands as you can.
A = B
If A and B are of the same type, value of B is simply assigned to A. More interest-
ing case is if A and B are of different types:
dim A as byte
dim B as word
...
B = 0xff0f
A = B
' A becomes $0f, higher byte $ff is lost
If A is more complex than B, then B is extended to fit the correct result:
dim A as word
dim B as byte
...
A = 0xff
B = A
' B becomes $00ff
ASSIGNMENT AND IMPLICIT CONVERSION
Overview
Notes
Examples