4.5.1 PIC Code Pages and Memory Banks

Next: 4.5.2 Adding New Devices Up: 4.5 The PIC14 port Previous: 4.5 The PIC14 port Contents Index

##
4.5.1 PIC Code Pages and Memory Banks

The linker organizes allocation for the code page and RAM banks. It does not have intimate knowledge of the code flow. It will put all the code section of a single .asm file into a single code page. In order to make use of multiple code pages, separate asm files must be used. The compiler assigns all static functions of a single .c file into the same code page.
To get the best results, follow these guidelines:

1. Make local functions static, as non static functions require code page selection overhead.
   Due to the way sdcc handles functions, place called functions prior to calling functions in the file wherever possible: Otherwise sdcc will insert unnecessary pagesel directives around the call, believing that the called function is externally defined.
2. For devices that have multiple code pages it is more efficient to use the same number of files as pages: Use up to 4 separate .c files for the 16F877, but only 2 files for the 16F874. This way the linker can put the code for each file into different code pages and there will be less page selection overhead.
3. And as for any 8 bit micro (especially for PIC14 as they have a very simple instruction set), use `unsigned char' wherever possible instead of `int'.

Next: 4.5.2 Adding New Devices Up: 4.5 The PIC14 port Previous: 4.5 The PIC14 port Contents Index