Download mikroPASCAL - PIC Vietnam
Transcript
mikroPASCAL
mikroPASCAL - Pascal Compiler for Microchip PIC microcontrollers
Example
making it simple...
if A + B > A then
First, compiler evaluates the expression on the left. During runtime, result is stored
in a variable of type that matches the largest data type in the expression. In this
case it is byte, as variables A and B are both bytes.
This is correct if the value does not exceed range 0..255, that is, if A + B is less
than 255.
Let's assume Aa is of word type :
if Aa + B > A ...
First, compiler evaluates the expression on the left. The result value is treated as
type that matches the largest data type in the expression. Since Aa is word and B
is byte, our result will be treated as word type.
This is correct if the value does not exceed range 0..65535, i.e. if Aa + B is less
than 65535.
{ if C is less than zero C := (-C) :}
if
C < 0 then
C := (-C);
{ Stay in loop while C is not equal to variable
compare_match; increment C in every cycle: }
while C <> compare_match
begin
C := C + 1;
end;
page
74
MikroElektronika: Development tools - Books - Compilers