what are the other compiler for microchip pic16/18/24

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Hi team

Just wondering what are the other compilers available for pic16/18/24, I am thinking giving the moving away from XC8 compiler.

thanks guys!
 

upand_at_them

Joined May 15, 2010
940
Very interesting, what project do you use it on?
Everything. Every time I develop something for PIC I do it in JAL. If I need to optimize, or I want a challenge, I'll convert it to assembly. I started with JAL many years ago because it's free and the C compilers for PIC were too pricey. I think there are libraries for most things I've ever needed. There's a library for SSD1306 coming out very soon, but I wrote my own anyway months ago.
 

nsaspook

Joined Aug 27, 2009
13,079
Hi team

Just wondering what are the other compilers available for pic16/18/24, I am thinking giving the moving away from XC8 compiler.

thanks guys!
What's the main issue. A C compiler for a 8-bit machine (any embedded system is unlikely to be 100% ANSI code) will be a bit of a kludge of the official spec.
https://embeddedgurus.com/stack-overflow/2009/12/efficient-c-code-for-8-bit-microcontrollers/

Integer promotion
The integer promotion rules of ANSI C are probably the most heinous crime committed against those of us who labor in the 8-bit world.
 
Last edited by a moderator:

Thread Starter

bug13

Joined Feb 13, 2012
2,002
What's the main issue. A C compiler for a 8-bit machine (any embedded system is unlikely to be 100% ANSI code) will be a bit of a kludge of the official spec.
https://embeddedgurus.com/stack-overflow/2009/12/efficient-c-code-for-8-bit-microcontrollers/

Integer promotion
The integer promotion rules of ANSI C are probably the most heinous crime committed against those of us who labor in the 8-bit world.
I have been bitten by the bug(or so as I believed) in the XC8 compiler a few time. It wasted me a lot of time. There are two that just happened in the last few weeks.

In the latest XC8 v2.20 (free version), if you have an array more than 256, something weird will happen. Once I reduced the array size to 256 or less, all the funny business went away.

Same version as above, it seems to have problem with structure:
C:
/* it sometime have problem with this
* accessing one member will change the
* value of the other member
*/
typedef struct TEST_A{
    uint8_t data1;
    uint16_t data2;
}test_a_t;

/* this one work fine */
typedef struct TEST_B{
    uint16_t data2;
    uint8_t data1;
}test_b_t;
 
Last edited by a moderator:

nsaspook

Joined Aug 27, 2009
13,079
I have been bitten by the bug(or so as I believed) in the XC8 compiler a few time. It wasted me a lot of time. There are two that just happened in the last few weeks.

In the latest XC8 v2.20 (free version), if you have an array more than 256, something weird will happen. Once I reduced the array size to 256 or less, all the funny business went away.

Same version as above, it seems to have problem with structure:
C:
/* it sometime have problem with this
* accessing one member will change the
* value of the other member
*/
typedef struct TEST_A{
    uint8_t data1;
    uint16_t data2;
}test_a_t;

/* this one work fine */
typedef struct TEST_B{
    uint16_t data2;
    uint8_t data1;
}test_b_t;
Hard to tell without a example but TEST_A data1 might get integer promoted to a int (16-bits in XC8) and overlap data2 during pointer int R/W operations. In TEST_B, a data1 int access won't affect data2 but it might affect the next variable in a contiguous memory space.
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Hard to tell without a example but TEST_A data1 might get integer promoted to a int (16-bits in XC8) and overlap data2 during pointer int R/W operations. In TEST_B, a data1 int access won't affect data2 but it might affect the next variable in a contiguous memory space.
Form what I can understand (meaning I would be wrong), integer promotion could be one thing, but the compiler over writing memory on a different location where it not suppose to is another.

In my case, my problem only happened on XC8 v2.20, it has no problem on an older version.
 

nsaspook

Joined Aug 27, 2009
13,079
Form what I can understand (meaning I would be wrong), integer promotion could be one thing, but the compiler over writing memory on a different location where it not suppose to is another.

In my case, my problem only happened on XC8 v2.20, it has no problem on an older version.
It should't be stomping on variables unless you tell it to.

Submit a trouble report/support case with a short example code for the error.
 

Ian Rogers

Joined Dec 12, 2012
1,136
In my case, my problem only happened on XC8 v2.20, it has no problem on an older version.
Looks like a ANSI C problem then... I have also experienced similar... BUT it was my old code.. C90 was more forgiving and C99 threw allsorts of errors... If it compiled on earlier versions just select C90 in the properties.. It will then be backwards compatible.... This is why C90 is still supported in V2.05
 
Top