XC8 to MIKROC migration

mikroC, mikroBasic and mikroPascal PRO for Microchip’s 8-bit PIC MCUs.
Post Reply
Author
Message
ktarchanidis
Posts: 5
Joined: 20 Jul 2020 14:52

XC8 to MIKROC migration

#1 Post by ktarchanidis » 23 Jul 2020 14:55

I'm trying to transfer my programs from Microchip XC8 to MIKROC PRO. In the XC8 I'm reading from EEPROM a Double which is in hex 0x00 00 60 40, that was in XC8 the float 3.5. Can anyone help me with the MIKROC version: how I'm I suppose to save it in EEPROM? The old 0x00 00 60 40 as shown in Watch Window of the ICD Debugger is NOT 3.5 neither the 0x40 60 00. How are float numbers laid in memory little or Big Endian?
Thank you

ktarchanidis
Posts: 5
Joined: 20 Jul 2020 14:52

Re: XC8 to MIKROC migration

#2 Post by ktarchanidis » 24 Jul 2020 08:53

Update:
I've checked with the ICD the Hex value of a variable set to 3.5 is 0x80 60 00 00. In the Help it says: <<Floating point in the mikroC PRO for PIC is implemented using the Microchip AN575 32-bit format (IEEE 754 compliant)>>.
An online hex calculator entering the 3.5 gives 0x40600000 (https://www.h-schmidt.net/FloatConverter/IEEE754.html). For the value of 33000.0 ICD gives 0x8E 00 E8 00 but the IEEE 754 format shows: 0x4700e800.
Can anyone tell me what format MIKROC is using?

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: XC8 to MIKROC migration

#3 Post by janni » 24 Jul 2020 12:40

mC uses little endian for storing numbers BUT floating-point numbers are stored in Microchip notation, not IEEE 754, like in XC8. The IDE contains Quick Converter where one may compare the formats.

EDIT: your second post was apparently delayed (first few posts usually are) so I haven't seen it before writing the above. If you need the details of Microchip format, see here.

ktarchanidis
Posts: 5
Joined: 20 Jul 2020 14:52

Re: XC8 to MIKROC migration

#4 Post by ktarchanidis » 24 Jul 2020 14:49

Thank you Janni.
Apparently Microchip itself is NOT using its notation. The code I have and is working and tested in nearly a thousand devices represents (in XC8) the 3.5 as 0x00006040 (IEEE754) and NOT as 0x80 60 00 00 (Microchip notation).
Nevertheless, I will change the code following this notation. It is a migration attempt anyway.
The most interesting part is due to come, trying the Visual TFT with an LCD display.
Best Regards

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: XC8 to MIKROC migration

#5 Post by janni » 25 Jul 2020 15:26

ktarchanidis wrote:
24 Jul 2020 14:49
Apparently Microchip itself is NOT using its notation.
Indeed. It comes from an old f-p library that has some quirks (unfortunately not corrected in mE compilers) from the times of mostly assembly programming. Still, the library is more compact and several times faster than the one used in XC8.

ktarchanidis
Posts: 5
Joined: 20 Jul 2020 14:52

Re: XC8 to MIKROC migration

#6 Post by ktarchanidis » 29 Jul 2020 12:37

janni wrote: "...library is more compact and several times faster than the one used in XC8"
YES!! That's why I've took the decision to swift to MIKROC.
The true confusion is with the PIC32 Harmony. Harmony is a Greek word and Microchip managed to invert its original meaning, it made it synonymous to chaos.
That will be my next step to change all my programs from Harmony to MIKROC for PIC32. I foresee a large volume of work (since the programs are huge) so I'm delaying it for now.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: XC8 to MIKROC migration

#7 Post by janni » 29 Jul 2020 20:47

ktarchanidis wrote:
29 Jul 2020 12:37
That will be my next step to change all my programs from Harmony to MIKROC for PIC32. I foresee a large volume of work (since the programs are huge) so I'm delaying it for now.
Just keep in mind that professional applications are not the target of mE compilers (hence the comparatively low price) so neither the compilers nor libraries are scrupulously tested, nor are any discovered quirks or bugs quickly fixed (or properly described). One also has to tolerate sometimes overlong implementation times of new processors. Having a look at some forum topics, like this one could be beneficial.

There's one thing more - at the moment mE transitions to NECTO studio so support of present compilers is hampered and will stop at some point. Better get a look at NECTO as it's quite a different experience.

Post Reply

Return to “PIC PRO Compilers”