Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 25, 2024, 03:18:52 15:18


Login with username, password and session length


Pages: [1]
Print
Author Topic: 32-bit int types in xc8?  (Read 8854 times)
0 Members and 1 Guest are viewing this topic.
alichan
Junior Member
**
Offline Offline

Posts: 94

Thank You
-Given: 28
-Receive: 88


« 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.
Logged
Signal
Active Member
***
Offline Offline

Posts: 197

Thank You
-Given: 111
-Receive: 81



« Reply #1 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.
Logged

Give a right name to a right game and play it right
biko4710
Newbie
*
Offline Offline

Posts: 33

Thank You
-Given: 45
-Receive: 40


« Reply #2 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.
Logged
alichan
Junior Member
**
Offline Offline

Posts: 94

Thank You
-Given: 28
-Receive: 88


« Reply #3 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 Smiley
Logged
Signal
Active Member
***
Offline Offline

Posts: 197

Thank You
-Given: 111
-Receive: 81



« Reply #4 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.
« Last Edit: June 02, 2015, 02:39:34 14:39 by Signal » Logged

Give a right name to a right game and play it right
flo0319
Junior Member
**
Offline Offline

Posts: 81

Thank You
-Given: 7
-Receive: 17


« Reply #5 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
Logged
Signal
Active Member
***
Offline Offline

Posts: 197

Thank You
-Given: 111
-Receive: 81



« Reply #6 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 Wink. lost in translation.
Logged

Give a right name to a right game and play it right
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC