Unlike the other PIC micro compilers the DSPICC STD 9.60 unfortunately has no code offset driver option. However one emulate the behaviour of a code offset option by offseting those psects which would be affected. A psect can be linked at a specific address, contiguously after a psect linked at a specific address or within a linker class. Those psects linked within a class can be offset in ROM by reserving the first 'offset' bytes using the --ROM driver option. The remaining psects can be offset by instructing the linker using the -L driver option.
Consider the following example output from the driver when it invokes the linker without a code offset. This output can be reproduced using the -v driver option for verbose output.
hlink --edf=/hitech/opt/dspicc/9.50/dat/eng_msgs.txt -h+test.sym -z -Q30F6014
-ol.obj -M/tmp/cgtKa3OS1 -ver=dsPICC#V9.60 -ACODE=0100h-0FFFFh,010000h-017FFFh
-ANEARCODE=0100h-0FFFFh -AXDATA=0800h-027FFh -AYDATA=01800h-027FFh
-ACONFIG=01F00000h-01F0001Ch -AVECTORS=00h-07Fh -AALTVECTOR=080h-0FFh
-preset_vec=0h,vectors=4h,altvectors=80h -pconfig=CONFIG -pconst=200h,strings
-pinit=CODE -pend_init=init -ppowerup=CODE -pidata=NEARCODE -pyidata=NEARCODE
-pbss=0800h,bitbss,nvram,nvbit,data,stack
-pybss=01800h,ybitbss,ydata,ynvram,ynvbit -pheap=-02800h
-pmconst=08100h,mstrings -peeprom=07FF000h -DCODE=2 -DNEARCODE=2 -DVECTORS=2
-DALTVECTOR=2 /tmp/cgtI5kMpi.obj test.obj
/hitech/opt/dspicc/9.50/lib/dspicc-sc.lib
If we required a code offset of 100h then we'd recompile with the following additional options to the driver: --ROM=default,-0-100
and -L-preset_vec=100h,vectors=104h,altvectors=180h
and -L-pconst=400h,strings
and -L-pmconst=08200h,mstrings
Note:
- The constant psects from both RAM and ROM are included because the RAM address space from 8000h is mapped directly into the rom space using the PSV mechanism.
- Due to the differences in addressing modes employed by the compiler between the RAM and ROM constant psects the offset applied to the ROM psects (i.e. const and strings) needs to be twice as much as for the other psects.
- Constant data is always linked low in memory within the first PSV page. Therefore any code offset applied will reduce the maximum amount of constant data available to the program.
Using this technique you can also be selective about which of the above psects you'd like to apply an offset to.
--------------------
Andrew Lanham,
Microchip Technology