User manual
221
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
Address and Indirection Operator
In the mikroPascal PRO for dsPIC30/33 and PIC24, address of an object in memory can be obtained by means of an
unary operator @. To reach the pointed object, we use an indirection operator ^ on a pointer. See Pointers section for
more details.
Operator Operation
^
accesses a value indirectly, through a pointer; result is the value at the address to
which operand points
@
constructs a pointer to its operand
See Pointers for more details on this subject
Note: Besides these, sizeof and explicit conversion unary operators are supported also.
Sizeof Operator
The prex unary operator sizeof returns an integer constant that represents the size of memory space (in bytes) used
by its operand (determined by its type, with some exceptions).
The operator sizeof can take either a type identier or an unary expression as an operand. You cannot use sizeof
with expressions of function type, incomplete types, parenthesized names of such types, or with lvalue that designates
a bit eld object.
Sizeof Applied to Expression
If applied to expression, the size of an operand is determined without evaluating the expression (and therefore without
side effects). The result of the operation will be the size of the type of the expression’s result.
Sizeof Applied to Type
If applied to a type identier, sizeof returns the size of the specied type. The unit for type size is sizeof(byte)
which is equivalent to one byte.
Thus:
sizeof(byte) // returns 1
sizeof(integer) // returns 2
sizeof(dword) // returns 4
sizeof(real) // returns 4
When the operand is a non-parameter of array type, the result is the total number of bytes in the array (in other words,
an array name is not converted to a pointer type):
var i, j : integer;
samples : array[10] of integer;
...
j := sizeof(samples[1]); // j = sizeof(integer) = 2
i := sizeof(samples); // i = 10*sizeof(integer) = 20