User manual

mikroPascal PRO for PIC32
MikroElektronika
207
@ Operator
The @ operator constructs a pointer to its operand. The following rules are applied to @:
- If X is a variable, @X returns a pointer to X.
Note : If variable X is of array type, the @ operator will return pointer to it's rst basic element, except when the left side
of the statement in which X is used is an array pointer.
In this case, the @ operator will return pointer to array, not to it's rst basic element.
program example;
var w : word;
ptr_b : ^byte;
ptr_arr : ^array[10] of byte;
arr : array[10] of byte;
begin
ptr_b := @arr; // @ operator will return ^byte
w := @arr; // @ operator will return ^byte
ptr_arr := @arr; // @ operator will return ^array[10] of byte
end.
- If F is a routine (a function or procedure), @F returns a pointer to F.
Related topics: Pointer Arithmetic
Pointer Arithmetic
Pointer arithmetic in the mikroPascal PRO for PIC32 is limited to:
- assigning one pointer to another,
- comparing two pointers,
- comparing pointer to zero,
- adding/subtracting pointer and an integer value,
- subtracting two pointers.
Assignment and Comparison
The simple assignment operator (=) can be used to assign value of one pointer to another if they are of the same
type.
Assigning the integer constant 0 to a pointer assigns a null pointer value to it.
Two pointers pointing to the same array may be compared by using relational operators =, <>, <, <=, >, and >=.
Results of these operations are the same as if they were used on subscript values of array elements in question: