4.2 Badram and Badrom Directives
The MPASM __BADRAM
and __BADROM
directives
along with the __MAXRAM
and __MAXROM
directives
specifies file register address ranges that should be flagged as being invalid should
they be used by code.
Suggested Replacement
There is no replacement for these directives.
Using the -mreserve
driver option will restrict linker
classes to the desired memory ranges. If you only use symbols defined in psects
placed into those classes, invalid memory areas will be avoided.
The_RAMSIZE
and _ROMSIZE
preprocessor
macros are also available and indicate the largest data and program memory space
address available with the selected target device.
#define DEST 0x7D0
PSECT text,CLASS=code,reloc=2 ;for PIC18 devices
;for other devices: PSECT text,class=CODE,delta=2
storeIt:
movlw 66
#if DEST > _ROMSIZE
#error "destination out of bounds"
#endif
BANKSEL (DEST)
movwf BANKMASK(DEST)
return
Note: The manual masking of addresses used as instruction operands
(for example using the
BANKMASK()
or PAGEMASK()
macros or ANDing the operand with a mask) is not necessary when using the
-Wl,--fixupoverflow
option and any of the
ignore
, warn
, or lstwarn
arguments.