ORG Define
It may sometimes be useful to move the start of the generated code to a
location other than 0. This can be used to move the program code beyond
a boot loader, for example. A Define has been added to the compiler to
allow a different reset address to be specified for the 14-bit core PIC
MCUs and the PIC18 parts.
Define RESET_ORG 100h
This Define moves the starting location of the program, the reset vector,
to the specified address. The interrupt vector(s) follow at their usual
offset, followed by the library and program code.
For 14-bit core devices with more than 2K of code space, only interrupts
in assembler may be used. On Interrupt will not work properly if the
device has more than 2K of code space and RESET_ORG is not 0. For
assembler interrupts in a device with more than 2K of code space and
RESET_ORG something other than 0, the values of W, STATUS and PCLATH must
be saved by whatever program now resides at the PIC MCU's fixed vector
locations before the jump to the new vector location. In general, the
save locations are named wsave, ssave and psave. The information on these
save locations should be provided with the boot loader or whatever program
requires the altered origination so that the register values may be restored
at the end of interrupt processing.
For 14-bit enhanced core devices with more than 2K of code space,
On Interrupt may be used but the values of W, STATUS and PCLATH must not be
changed to get to the interrupt vector as they will not be restored upon
return from the interrupt. This usually means bra will be used to jump to
the new interrupt vector location. Interrupts in assembler do not require
any special treatment.
Either 14-bit core PBP library must fit into the first 2K of code space.
The PIC18 PBP library must fit into the first 32K of code space. It is best
for RESET_ORG to start on an even 256 word boundary.
Bookmarks