4.8.1.2 PSV Data Window
The psvpage()
and psvoffset()
operators can be used with the PSV data window. These operators may be applied to any symbol (usually representing a table of constant data) in program memory.
Suppose a table of constant data is declared in program memory like this:
.section *,psv
fib_data:
.word 0, 1, 2, 3, 5, 8, 13
To access this table through the PSV data window, use the psvpage()
and psvoffset()
operators as follows:
; Enable Program Space Visibility (Note 1)
bset.b CORCONL, #PSV
; Set PSVPAG (Note 2) to the page that contains the fib_data array.
mov #psvpage(fib_data), w0
mov w0, _PSVPAG
; Make a pointer to fib_data in the PSV data window
mov #psvoffset(fib_data), w0
; Load the first data value
mov [w0++], w1
For devices with EDS, use DSRPAG
. Please check the data sheet for your device.
The programmer must ensure that the constant data table does not exceed the program memory page size that is implied by the PSVPAG register (or the DSRPAG register for devices with EDS). The maximum table size implied by the PSVPAG or DSRPAG register is 32 Kbytes. If additional constant data storage is required, simply create additional tables each with its own symbol, and repeat the code sequence above to load the PSVPAG or DSRPAG register and derive a pointer.