4.6.1.3 Codeoffset Option
The -mcodeoffset=offset
option shifts up
in memory the entry locations for the code normally linked to the reset and interrupt
vectors by the specified offset, and prevents regular code and data from using memory up to
this offset address. This operation is commonly required when writing bootloaders.
The address is assumed to be a hexadecimal constant. A leading
0x
, or a trailing h
hexadecimal specifier can be used
but is not necessary.
This option does not affect the location of the interrupt vector table for those devices that support vectored interrupts, nor does it affect the low- or high-priority interrupt vectors for the same devices operating in legacy mode. Adjust the IVTBASE register to perform either of these two tasks.
As an example, the option -mcodeoffset=600
will link the
entry point for the reset code at address 0x600 rather than address 0x0; and link the
interrupt routine at address 0x604 rather than 0x4, in the case of mid-range PIC devices,
or at the addresses 0x608 and 0x618 for PIC18 devices. No code or data will be placed at
the addresses 0 through 0x5FF unless the program explicitly places anything in this
range.
As the reset and interrupt vector locations are at fixed addresses in the PIC device, it is the programmer’s responsibility to provide code that can redirect control from the actual vector locations to the entry points of the reset and interrupt routines in their offset location. The compiler will also not generate the runtime startup code to initialize the oscillator with the calibration constant when this would otherwise be performed. It is expected that the redirection code will provide this functionality if required.