4.1 Access_ovr Directive
On PIC18 devices, the MPASM ACCESS_OVR
directive declares
the beginning of a section of overlaid data in Access Bank RAM.
Suggested Replacement
Define a psect with the ovrld
flag set. Associate the psect with the
Access bank linker class, COMRAM
to have it linked somewhere in the
PIC18's Access Bank.
The example following shows objects placed into the
myData
psect, which is used in two different modules (file 1
and file 2). The PSECT
directive uses the same psect name,
ovrld
flag (to indicate that the psects will be overlaid), and
space=1
flag (to indicate the psects will reside in the data
space memory). The psects are associated with the PIC18 COMRAM
linker class, which defines the Access Bank memory, so once overlaid,
myData
will appear anywhere in the memory defined by this
class.
;file 1
PSECT myData,space=1,ovrld,class=COMRAM
zero:
DS 1
;leave a 1-byte gap for another object here
ORG 2
two:
DS 1
;file 2
PSECT myData,space=1,ovrld,class=COMRAM
ORG 1
one:
DS 1
Note that the contributions to an overlaid psect are concatenated in
each module, but the psects from each module are then overlaid at link time. When
the above example is built, the labels will appear in memory in the order
zero
, one
, two
.
The ORG
directive in the above example has allowed the
psects' content to interleave. If this directive had not been used in file 1, the
space associated with the label zero
and the label
one
would overlap, and these objects would appear at the same
address. Such code is legal and may be desired in some applications.
Overlaid psects can be linked into any RAM area, not just the Access bank, and this construct will work on any device with the selection of a suitable linker class.