Positron Compiler Documentation

AddressOf

Source: Positron8 Compiler User Manual, PDF page 320

Syntax

Assignment Variable = AddressOf ( Variable )

Overview

Returns the address of the variable in RAM, or a label in Code memory. Commonly known as a pointer.

Parameters

Assignment Variable can be any of the compiler's variable types, and will receive the pointer to the variable's address. Variable can be any variable name used in the BASIC program.

Notes

Be careful if using AddressOf to locate the starting address of an array when using an older standard 14-bit device, because arrays can cross RAM bank boundaries, and the finishing address of the array may be in a different RAM bank to its start address. The compiler can track RAM bank changes internally when accessing arrays on the older standard 14-bit core devices, but a user’s BASIC program, generally, cannot. For example, the most common use for AddressOf is when implementing indirect addressing using the microcontroller's FSR and INDF registers.

This is not the case with 18F devices, as the FSR0, FSR1, and FSR2 registers can access all memory areas linearly the same with enhanced 14-bit core devices, because they contain FSR0 and FSR1 SFRs.

When using AddressOf with an enhanced 14-bit core device it will return the address of a variable or label plus the offsets required to make them linearly accessible. i.e. $2000 for RAM and $8000 for Flash memory.