4.58 Udata_ovr Directive
For Baseline and Mid-range devices, the MPASM UDATA_OVR
directive creates an overlaid section for objects that are uninitialised.
Suggested Replacement
Define a psect with the ovrld flag set. Associate the
psect with the access bank linker class, COMMON to have it linked
somewhere in the common memory on Baseline or Mid-range devices.
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 COMMON linker
class, which defines the common memory, so once overlaid, myData
will appear anywhere in the memory defined by this class.
;file 1
PSECT myData,space=1,ovrld,class=COMMON
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=COMMON
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 common memory. This construct will work on any device with the selection of a suitable linker class.
