3 byte variables [feature request]

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

3 byte variables [feature request]

kuldeep dhaka
while working on a program i faced a problem.
i need only 20 bit , and having a 32 bit only waste more memory(12 byte),
24bit would much be better.
i need a uint24_t variable but gcc dont support it so i have to start with
uint32_t.
it would be very nice if gcc support such variables.
i tried a little program and found that gcc (on i686) dont support it.

http://embeddedgurus.com/stack-overflow/2009/06/three-byte-integers/

--
*Kuldeep Singh Dhaka*
+91-8791676237
[hidden email]
Programmer, Open Source, Web Developer, System Administrator, Entrepreneur,
Animal Lover, Student, Reverse Engineer, Embedded System, Learning.

Bitcoins Accepted.
My GnuPG Public
Key<http://pgp.mit.edu:11371/pks/lookup?op=get&fingerprint=on&search=0x23816C5609DC7E26>
Fork Me <https://github.com/kuldeepdhaka>

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: 3 byte variables [feature request]

Peter Bigot-4
Best to submit this to the gcc project; it's certainly not something that
would be added through mspgcc.

int20_t was an enhancement I thought useful since the MSP430 CPUX
architecture enables it, but I don't have reason to believe other MSP430
toolchains (including the upcoming RH GCC) will recognize it.  Native
support for it on CPUX still requires 32-bits when it's written to memory,
though, and that wouldn't change since its inherent in the way the
instruction set works.

Peter


On Wed, Jun 5, 2013 at 8:53 AM, kuldeep dhaka <[hidden email]>wrote:

> while working on a program i faced a problem.
> i need only 20 bit , and having a 32 bit only waste more memory(12 byte),
> 24bit would much be better.
> i need a uint24_t variable but gcc dont support it so i have to start with
> uint32_t.
> it would be very nice if gcc support such variables.
> i tried a little program and found that gcc (on i686) dont support it.
>
> http://embeddedgurus.com/stack-overflow/2009/06/three-byte-integers/
>
> --
> *Kuldeep Singh Dhaka*
> +91-8791676237
> [hidden email]
> Programmer, Open Source, Web Developer, System Administrator, Entrepreneur,
> Animal Lover, Student, Reverse Engineer, Embedded System, Learning.
>
> Bitcoins Accepted.
> My GnuPG Public
> Key<
> http://pgp.mit.edu:11371/pks/lookup?op=get&fingerprint=on&search=0x23816C5609DC7E26
> >
> Fork Me <https://github.com/kuldeepdhaka>
>
>
> ------------------------------------------------------------------------------
> How ServiceNow helps IT people transform IT departments:
> 1. A cloud service to automate IT design, transition and operations
> 2. Dashboards that offer high-level views of enterprise services
> 3. A single system of record for all IT processes
> http://p.sf.net/sfu/servicenow-d2d-j
> _______________________________________________
> Mspgcc-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>
>

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: 3 byte variables [feature request]

David Brown-40

24-bit integers would have to be 16-bit aligned for the cpu to be able
to load them efficiently, those negating any storage benefits.  So to be
able to store them efficiently, you would effectively have a struct
containing three 8-bit bytes (or an array of three bytes).  I think the
best you could do here is to make a C++ class containing these three
bytes, with conversion operations to and from int20_t types.  It should
be possible to do this with code that is almost as efficient as a real
gcc implementation.

mvh.,

David


On 05/06/13 16:09, Peter Bigot wrote:

> Best to submit this to the gcc project; it's certainly not something that
> would be added through mspgcc.
>
> int20_t was an enhancement I thought useful since the MSP430 CPUX
> architecture enables it, but I don't have reason to believe other MSP430
> toolchains (including the upcoming RH GCC) will recognize it.  Native
> support for it on CPUX still requires 32-bits when it's written to memory,
> though, and that wouldn't change since its inherent in the way the
> instruction set works.
>
> Peter
>
>
> On Wed, Jun 5, 2013 at 8:53 AM, kuldeep dhaka <[hidden email]>wrote:
>
>> while working on a program i faced a problem.
>> i need only 20 bit , and having a 32 bit only waste more memory(12 byte),
>> 24bit would much be better.
>> i need a uint24_t variable but gcc dont support it so i have to start with
>> uint32_t.
>> it would be very nice if gcc support such variables.
>> i tried a little program and found that gcc (on i686) dont support it.
>>
>> http://embeddedgurus.com/stack-overflow/2009/06/three-byte-integers/
>>


------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users
Reply | Threaded
Open this post in threaded view
|

Re: 3 byte variables [feature request]

Peter Bigot-4
Keep in mind that, even with a "real gcc implementation", that code would
still be very inefficient due to weaknesses in the MSP430 CPUX instruction
set.  Getting the upper 4 bits into and out of a 20-bit register is a
computationally complex operation.  The best approach I've found that
doesn't require a word-aligned memory location involves a 5-bit
rotate-through-carry.  Casts between 32-bit and 20-bit values on the MSP430
are extremely expensive.


On Wed, Jun 5, 2013 at 3:22 PM, David Brown <[hidden email]>wrote:

>
> 24-bit integers would have to be 16-bit aligned for the cpu to be able to
> load them efficiently, those negating any storage benefits.  So to be able
> to store them efficiently, you would effectively have a struct containing
> three 8-bit bytes (or an array of three bytes).  I think the best you could
> do here is to make a C++ class containing these three bytes, with
> conversion operations to and from int20_t types.  It should be possible to
> do this with code that is almost as efficient as a real gcc implementation.
>
> mvh.,
>
> David
>
>
>
> On 05/06/13 16:09, Peter Bigot wrote:
>
>> Best to submit this to the gcc project; it's certainly not something that
>> would be added through mspgcc.
>>
>> int20_t was an enhancement I thought useful since the MSP430 CPUX
>> architecture enables it, but I don't have reason to believe other MSP430
>> toolchains (including the upcoming RH GCC) will recognize it.  Native
>> support for it on CPUX still requires 32-bits when it's written to memory,
>> though, and that wouldn't change since its inherent in the way the
>> instruction set works.
>>
>> Peter
>>
>>
>> On Wed, Jun 5, 2013 at 8:53 AM, kuldeep dhaka <[hidden email]>**
>> wrote:
>>
>>  while working on a program i faced a problem.
>>> i need only 20 bit , and having a 32 bit only waste more memory(12 byte),
>>> 24bit would much be better.
>>> i need a uint24_t variable but gcc dont support it so i have to start
>>> with
>>> uint32_t.
>>> it would be very nice if gcc support such variables.
>>> i tried a little program and found that gcc (on i686) dont support it.
>>>
>>> http://embeddedgurus.com/**stack-overflow/2009/06/three-**byte-integers/<http://embeddedgurus.com/stack-overflow/2009/06/three-byte-integers/>
>>>
>>>
>

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
Mspgcc-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users