4.6.1.3 Codeoffset Option

The -mcodeoffset=offset option shifts the reset and interrupt vector locations up in memory, by the specified offset, preventing 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 move the reset vector from address 0 to 0x600; and move the interrupt vector from address 4 to 0x604, in the case of mid-range PIC devices, or to the addresses 0x608 and 0x618 for PIC18 devices. No code or data will be placed at the addresses 0 thru 0x5FF.

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 reset and interrupt routines in their offset location.