Sonsivri

Electronics => Pic C Languages => Topic started by: alichan on May 31, 2015, 07:25:10 19:25



Title: 32-bit int types in xc8?
Post by: alichan on May 31, 2015, 07:25:10 19:25
Hello.

I'm trying to use 32-bit integers and I noticed the compiler always generates 24-bits types. It's pointless if i use "unsigned long", "long long", or c99 "uint32_t"... always i get 24-bit sizes. I'm not sure if it needed to activate an option when calling the compiler to generate true 32-bit types.
I read the compiler manuals, forums, etc. looking for some clue, unsuccessfully. Surely I missed something, but dunno what.

Any suggestion?

Ty.


Title: Re: 32-bit int types in xc8?
Post by: Signal on May 31, 2015, 11:33:15 23:33
Maybe 24 bit is not the limit of the type but the limit of the method you use for checking the limit? library function for print/trace values? I suggest two things. Show the minimal testing code you have trouble with. And try the microchip forum - it is rather fast in solving such problems and is a correct place to post if you'd like to get a bugfix in next release soon.


Title: Re: 32-bit int types in xc8?
Post by: biko4710 on May 31, 2015, 11:55:59 23:55
If you are using MPLAB X 2.xx, default is to use 24bit with XC8.
Check your make output:
  "D:\Microchip\xc8\v1.31\bin\xc8.exe" --pass1  --chip=16F1825 -Q -G  --double=24 --float=24 --opt=default,...

You can change that:
1. Navigate to project properties
2. Select XC8 linker (it is found in the categories pane then under XC8 global options)
3.To the right on the top, there is a drop down box labeled option categories -> select "Memory model"
4. Specify the size of a double and the size of a float from either 24 or 32 bit.


Title: Re: 32-bit int types in xc8?
Post by: alichan on June 02, 2015, 01:11:55 01:11
Maybe 24 bit is not the limit of the type but the limit of the method you use for checking the limit? library function for print/trace values? I suggest two things. Show the minimal testing code you have trouble with. And try the microchip forum - it is rather fast in solving such problems and is a correct place to post if you'd like to get a bugfix in next release soon.

The code is so simple as:

uint32_t test; or long long test;

But it found the problem was a simple visual issue, the disassembled code wasn't grouped so some instructions appeared before the disassembled instruction making it look as if the asm didn't belong to that instruction... but code is really correct, only a f******* visual issue together some fancy compiler optimizations that screwed things more. All solved now.


Ty to both :)


Title: Re: 32-bit int types in xc8?
Post by: Signal on June 02, 2015, 01:55:14 13:55
... All solved now.

Since biko4710's note was not about integer types but about float and double, it is unclear what is your solution and what was the exact source of that problem. Please share your experience more suitable to reuse.


Title: Re: 32-bit int types in xc8?
Post by: flo0319 on June 02, 2015, 08:43:13 20:43
XC8 implement  signed/unsigned (long) long types on 32bits. You can find a table in MPLAB_XC8_C_Compiler_User_Guide.pdf ( your compiler root >  xc8 > version > docs) 5.4.2 Integer Data types ( page 147 on v1.33)

How you noticed that is generated only 24bits? I am using this compiler and I am 100% sure that the uint32 has 32bits, maybe Signal is right, the problem can be your method used to check it


Title: Re: 32-bit int types in xc8?
Post by: Signal on June 02, 2015, 11:48:41 23:48
I have just re-read the last post of alichan. It seems that too expressive text shaded the simple truth - there was no problem with a compiler, just false alarm. Hence nothing was solved actually ;). lost in translation.