I am currently in the process of porting my C program from SDCC to Keil because of several reasons. (bugs, lack of support, limitations)
What I would like to know is how some of the syntax changes look like.
So far I have figured out that __xdata becomes xdata and I cannot enter binary values.
I am having a lot of issues with the keil compiler at the moment so I will keep it short.
The special functions registers look like: __sfr __at 0xE0 ACC ;
I believe this must look like: sfr ACC = 0xE0; correct?
And is the same true for sbit?
__sbit __at 0x88 IT0 ; --> sbit IT0 = 0x88; ???
Than I'd like to know how the interrupt syntax looks like. It currently looks like this: void ISR_ex0(void) __interrupt 0
A huge problem we're having is that this interrupt 0 in SDCC is linked to a certain stack address (0x03). In SDCC I have no control over the link between address and interrupt numbers. This is baked in the compiler. I am programming an emulated 80c51 chip. The 'chip' is emulated on an FPGA and it comes with a lot of extras such as extra timers, 4 more I/O ports and 8 I/O interrupts rather than two. Now I can only use 2/8 interrupts.
As already noted, porting from one compiler to another will always require a thorough study of the documentation for both compilers - in particular, the implementation-defined standard aspects and any non-standard extensions.
The usual approach is to "wrap" the dependencies in conditional compilation; eg,
#if defined SDCC #define XDATA __xdata #elif deinfed KEIL #define XDATA xdata #else #error "Unknown compiler" #endif
You will have to look up the actual symbols to identify the two compilers.
I would suggest that you maintain both versions - so that you can always go back to the SDCC version to check that your Keil version is still working as required.
If you're lucky, you might find that someone has already done this ...
If you're lucky, you might find that someone has already done this .
most (all?) SiLabs sample code can run either SDCC or Keil