Sunday, February 18, 2018

It could be something...


I've added some recent tests, including a new version of XC8 compiler (1.45) and the SDCC compiler (3.6.9 #10225). a development version.  The results are surprising. First here is the SDCC that performs better than the 1.33 version of the XC8 compiler (in free mode), and second, the new version of the XC8 performs better in free mode than the JALv2 compiler that has all the optimizations active.

Original article:

At the article's date (December 19, 2014), MPLAB XC8 compiler is at 1.33 version and shockingly, it scores smaller code sizes in the free version than the older and unsupported MPLAB C18 in his commercial version. Regarding compiling bootloaders, C18 still remain the only alternative between the two, but anything else can be successfully compiled with XC8.

Well, "anything else" means all I have tested so far, in the form of a common code (the code can be compiled without modifications by both compilers) for custom libraries and projects and that is:

  •  - I2C library;
  •  - hardware serial comm. library;
  •  - non-blocking delays library;
  •  - 4bit LCD HD44780 library with arbitrary pinout;
  •  - PCF8583 RTC applications displaying on LCD or sending on serial;
  •  - Blinking LED with non-blocking delays, in both sloted (JALv2 with Jallib) and millis (Arduino) ways.

By example, compiling pcf8583_lcd example for PIC18F46K22, we get:

new tests:

- with XC8 1.45 in free mode:
  - 70 bytes RAM;
  - 2424 bytes FLASH;

- with SDCC 2.6.9 #10225 with optimizations enabled:
  - 6 bytes RAM;
  - 3000 bytes FLASH;

old tests:

- with XC8 1.33 in free mode;
 - 77 bytes RAM;
 - 3630 bytes FLASH;

- with C18 3.46 without procedural abstraction:
 - 302 bytes RAM;
 - 18394 bytes FLASH.

- with C18 3.46 with procedural abstraction:
 - 302 bytes RAM;
 - 7050 bytes FLASH.

As a side note, this is compilation result using Jalv2 (considering this, I always wondered why hobbyists have struggled for so long with MCHP C18 compiler!):

- with JALv2.4q3 with Jallib libraries (in fact, the code is even smaller then reported, as JAL counts also the 768 bytes from the AN1310 bootloader):
 - 70 bytes RAM;
 - 2460 bytes FLASH.

There are plans for adding more libraries for graphical displays, Dallas temperature sensors, SD-Card and FAT32 file system, Infrared, 7-seg. LED displays, Stepper and Servo motors and anything else that may be useful.

What is so special at these libraries? Nothing. Except that is a common code across more compilers and languages, including JALv2 and PMP (library in progress) compilers and, apart of the fact that it will offer good features for custom projects and a "common language" which will assure a smooth transition from a language to another, it will provide also an absolute fair platform for "smackdowns" between compilers.

It is a big project and let's hope that I will have the energy to successfully finalize it.
Not yet ready for public, but already functional, the project is online at (there are projects for the MPLAB-X IDE + XC8 combination; for the Eclipse IDE + SDCC combination, you will find the repository address here).

No comments:

Post a Comment