Microchip’s FREE optimizing compilers are great, but are you sure you’re getting all of the code size benefit that you can from them? For backwards compatibility reasons, not all of the optimizations are turned on by default. All optimizations are easily controlled from the project properties in MPLAB® X IDE. For MPLAB® XC8, there are three important selections: choose “Generated Assembler Code” and “Assembler Files” and make sure you deselect “Speed.” This will give you the tightest code generation.
It’s even simpler for MPLAB® XC16 and XC32. In the same project properties, simply choose Optimization Level 1.
That’s all it takes to get the smallest possible code size for all of the FREE optimizing MPLAB® XC compilers!