4.2 User-defined Psects for Mid-range and Baseline Devices

This chapter's example code places the entry-point code associated with Reset in a user-defined psect, as was done in the equivalent PIC18 example code shown in section A Basic Example For PIC18 Devices. The definition for this psect, however, looks a little different to that used by the PIC18 code and is given by the line:
PSECT resetVec,class=CODE,delta=2

Notice that the reloc=2 flag that was used in the PIC18 example is not necessary with psects that hold code for Mid-range or Baseline devices. As this flag has not been specified, the reloc value defaults to 1, which implies that this psect will not be word aligned. Instructions on Mid-range or Baseline devices can be located at any address, so no word alignment is necessary.

The new psect flag that has been used with resetVec is the delta flag. A delta value of 2 indicates that 2 bytes reside at each address in the memory space where this psect will be located. This agrees with the program memory implemented on Mid-range and Baseline devices, which is either 14 or 12 bits wide (respectively) and which requires 2 whole bytes to program. PIC18 devices, on the other hand, define 1 byte of memory at each address, hence the delta value associated with psects holding code for those devices should be set to 1 (the default value if no delta flag is used).

Any program memory psect holding executable code on a Mid-range or Baseline devices must set the delta flag to 2. Psects destined for data memory or psects used with other devices should omit the delta flag or explicitly set the flag value to 1.