User`s manual
mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
98
mikroBASIC
MikroElektronika: Development tools - Books - Compilers
In order to get the most from your mikroBasic compiler, you should be familiar
with certain aspects of PIC MCU. This chapter is not essential, but it can provide
you a better understanding of PICs' capabilities and limitations, and their impact
on the code writing.
For start, you should know that arithmetical operations such as addition and sub-
traction are carried out by ALU (Arithmetical Logical Unit). With PIC MCUs
(series PIC16 and PIC18), ALU is optimized for working with bytes. mikroBasic
is capable of handling much more complex data types, but note that these can
increase the time needed for performing even simple operations.
Also, not all PIC MCU models are of equal performance. PIC16 series lacks hard-
ware resources to multiply two bytes in HW - it is carried out by software algo-
rithm generated by mikroBasic. On the other hand, PIC18 series has HW multipli-
er, and as a result, multiplication works considerably faster.
Loops are convincing examples of byte type efficiency, especially if statements
repeated hundreds of times are involved. Consider the following lines:
for i = 1 to 100
tA = ta + 1
next i
...
for ii = 1 to 100
Aa = Aa + 1
next ii
where i and A are variables of byte type, and ii and Aa are variables of word type.
First loop will be executed considerably faster.
Although memory management is completely under the compiler's control, you
can explicitly assign address to variable by means of directive absolute. See
Directives for more information.
NOTE : Be aware that nested function and procedure calls have limited depth - 8
for PIC16 series and 31 for PIC18 series.
PIC MCU SPECIFIC
making it simple...
page