24 bit Integer

View: New views
11 Messages — Rating Filter:   Alert me  

24 bit Integer

by Moritz Struebe :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi everyone,

I was just wondering whether it's theoretically possible to use a 24bit
Integer, and whether there is certain reason why 24bit aren't supported.

Cheers
Morty



_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

RE: 24 bit Integer

by Weddington, Eric-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 

> -----Original Message-----
> From:
> avr-gcc-list-bounces+eweddington=cso.atmel.com@...
> [mailto:avr-gcc-list-bounces+eweddington=cso.atmel.com@nongnu.
> org] On Behalf Of Moritz Struebe
> Sent: Monday, July 14, 2008 8:32 AM
> To: avr-gcc-list@...
> Subject: [avr-gcc-list] 24 bit Integer
>
> Hi everyone,
>
> I was just wondering whether it's theoretically possible to
> use a 24bit
> Integer, and whether there is certain reason why 24bit aren't
> supported.
>

A 24-bit integer is not supported by the C language. In theory, support
could be added to GCC, but then it would be considered an extension to
the C language. And it would also be difficult and/or time-consuming to
add to GCC.

But personally, I would like to see support added for 24-bit integer
types as the AVR port could really use 24-bit pointers for larger
devices (ATmega256x, avr6 architecture).


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Re: 24 bit Integer

by David Kelly :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jul 14, 2008 at 08:39:50AM -0600, Weddington, Eric wrote:

>  
> > I was just wondering whether it's theoretically possible to use a
> > 24bit Integer, and whether there is certain reason why 24bit aren't
> > supported.
>
> A 24-bit integer is not supported by the C language. In theory,
> support could be added to GCC, but then it would be considered an
> extension to the C language. And it would also be difficult and/or
> time-consuming to add to GCC.
>
> But personally, I would like to see support added for 24-bit integer
> types as the AVR port could really use 24-bit pointers for larger
> devices (ATmega256x, avr6 architecture).

CodeWarrior for the 68HC12 uses 24 bit *far pointers. Perhaps gcc for
HC12 does too? One of the funky things about *far in HC12 is that the
bytes are not in the same order as one might expect if promoted to 32
bits.

If one absolutely had to have 24 bit integers one could construct a 3
byte struct, or probably better yet a union of several structs. Would
have to handle the math separately.

typedef union {
        uint8_t a[3]; // array

        struct {
                uint16_t ab;
                uint8_t c;
        } big_little;

        struct {
                uint8_t a;
                uint16_t bc;
        } little_big;

        struct {
                uint8_t a, b, c;
        } byte;

} MY24BITS;


--
David Kelly N4HHE, dkelly@...
========================================================================
Whom computers would destroy, they must first drive mad.


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Re: 24 bit Integer

by Clint Lawrence :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2008/7/14 Weddington, Eric <eweddington@...>:
> A 24-bit integer is not supported by the C language. In theory, support
> could be added to GCC, but then it would be considered an extension to
> the C language. And it would also be difficult and/or time-consuming to
> add to GCC.

The C standard doesn't dictate the size of any integer type, except that char
must be large enough to hold the environments standard character set and
the size of any larger types is ordered as you'd expect.
char <= short <= int <= long
int is typically the natural word size for the architecture, but often on 8 bit
micros it will be larger (since char typically provides an 8 bit int anyway.)

Cheers,
Clint


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

RE: 24 bit Integer

by Dave Hansen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.


From: clint.lawrence@...

> 2008/7/14 Weddington, Eric <eweddington@...>:
> > A 24-bit integer is not supported by the C language. In theory, support
> > could be added to GCC, but then it would be considered an extension to
> > the C language. And it would also be difficult and/or time-consuming to
> > add to GCC.
>
> The C standard doesn't dictate the size of any integer type, except that char
> must be large enough to hold the environments standard character set and
> the size of any larger types is ordered as you'd expect.
> char <= short <= int <= long
 
Also that short and int must be able to represent at least -32767 to +32767, and long must be able to represent +/-2,147,483,647.  So int24_t would have to be a special type outside the standard types.
 
And I think (though I'm not certain) that it would have to be promoted to long before any operator could be applied.  Some of that would be mitigated by the as-if rule, of course...

> int is typically the natural word size for the architecture, but often on 8 bit
> micros it will be larger (since char typically provides an 8 bit int anyway.)

It's larger because an 8 bits can't represent the required range of values.
 
Regards,
 
   -=Dave
 


Time for vacation? WIN what you need. Enter Now!
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Re: 24 bit Integer

by Steven Michalske :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

what about a PDP 8 or PDP 15,  could we not code for it?   being 12 and 18 bit machines?

Steve

On Jul 30, 2008, at 8:36 AM, Dave Hansen wrote:



From: clint.lawrence@...

> 2008/7/14 Weddington, Eric <eweddington@...>:
> > A 24-bit integer is not supported by the C language. In theory, support
> > could be added to GCC, but then it would be considered an extension to
> > the C language. And it would also be difficult and/or time-consuming to
> > add to GCC.
> 
> The C standard doesn't dictate the size of any integer type, except that char
> must be large enough to hold the environments standard character set and
> the size of any larger types is ordered as you'd expect.
> char <= short <= int <= long
 
Also that short and int must be able to represent at least -32767 to +32767, and long must be able to represent +/-2,147,483,647.  So int24_t would have to be a special type outside the standard types.
 
And I think (though I'm not certain) that it would have to be promoted to long before any operator could be applied.  Some of that would be mitigated by the as-if rule, of course...

> int is typically the natural word size for the architecture, but often on 8 bit
> micros it will be larger (since char typically provides an 8 bit int anyway.)

It's larger because an 8 bits can't represent the required range of values.
 
Regards,
 
   -=Dave
 


Time for vacation? WIN what you need. Enter Now! _______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

RE: 24 bit Integer

by Weddington, Eric-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

 

> -----Original Message-----
> From:
> avr-gcc-list-bounces+eweddington=cso.atmel.com@...
> [mailto:avr-gcc-list-bounces+eweddington=cso.atmel.com@nongnu.
> org] On Behalf Of Steven Michalske
> Sent: Wednesday, July 30, 2008 8:38 PM
> To: avr-gcc List
> Subject: Re: [avr-gcc-list] 24 bit Integer
>
> what about a PDP 8 or PDP 15,  could we not code for it?  
> being 12 and 18 bit machines?
>

Does GCC have a target for the PDP-8 or PDP-15?

And somehow I don't think that it relates to AVR GCC...


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

RE: 24 bit Integer

by Dave Hansen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


For a PDP-8, CHAR_BIT would be 12, int could have 24 bits, and long could have 36 or 48, whatever is most convenient/efficient/desired.  

For a PDP-15, char and int could be the same 18-bit type, and long could be 36 bits.

On further reflection, you might be able to replace the standard 16 bit int on AVR with a 24 bit int.  The required ranges are minimums.  That makes int16_t a special type outside the normal hierarchy, however, and I'm not certain that's allowed.

Regards,

   -=Dave



________________________________

From: smichalske@...
[...]
what about a PDP 8 or PDP 15,  could we not code for it?   being 12 and 18 bit machines?


From: clint.lawrence@...

> 2008/7/14 Weddington, Eric <eweddington@...>:
>> A 24-bit integer is not supported by the C language. In theory, support
>> could be added to GCC, but then it would be considered an extension to
>> the C language. And it would also be difficult and/or time-consuming to
>> add to GCC.
>
> The C standard doesn't dictate the size of any integer type, except that char
> must be large enough to hold the environments standard character set and
> the size of any larger types is ordered as you'd expect.
> char <= short <= int <= long

Also that short and int must be able to represent at least -32767 to +32767, and long must be able to represent +/-2,147,483,647.  So int24_t would have to be a special type outside the standard types.

And I think (though I'm not certain) that it would have to be promoted to long before any operator could be applied.  Some of that would be mitigated by the as-if rule, of course...

> int is typically the natural word size for the architecture, but often on 8 bit
> micros it will be larger (since char typically provides an 8 bit int anyway.)

It's larger because an 8 bits can't represent the required range of values.

Regards,

   -=Dave



________________________________

Time for vacation? WIN what you need. Enter Now! _______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


_________________________________________________________________
With Windows Live for mobile, your contacts travel with you.
http://www.windowslive.com/mobile/overview.html?ocid=TXT_TAGLM_WL_mobile_072008

_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

RE: 24 bit Integer

by Stu Bell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

HAH!  Hey, how about a Univac SolidState-80 (circa 1959)?  5000 bi-quint words!  Can we code for that?
 
Stu ( :-P )


From: avr-gcc-list-bounces+sbell=dataplay.com@... [mailto:avr-gcc-list-bounces+sbell=dataplay.com@...] On Behalf Of Steven Michalske
Sent: Wednesday, July 30, 2008 8:38 PM
To: avr-gcc List
Subject: Re: [avr-gcc-list] 24 bit Integer

what about a PDP 8 or PDP 15,  could we not code for it?   being 12 and 18 bit machines?

Steve

On Jul 30, 2008, at 8:36 AM, Dave Hansen wrote:



From: clint.lawrence@...

> 2008/7/14 Weddington, Eric <eweddington@...>:
> > A 24-bit integer is not supported by the C language. In theory, support
> > could be added to GCC, but then it would be considered an extension to
> > the C language. And it would also be difficult and/or time-consuming to
> > add to GCC.
> 
> The C standard doesn't dictate the size of any integer type, except that char
> must be large enough to hold the environments standard character set and
> the size of any larger types is ordered as you'd expect.
> char <= short <= int <= long
 
Also that short and int must be able to represent at least -32767 to +32767, and long must be able to represent +/-2,147,483,647.  So int24_t would have to be a special type outside the standard types.
 
And I think (though I'm not certain) that it would have to be promoted to long before any operator could be applied.  Some of that would be mitigated by the as-if rule, of course...

> int is typically the natural word size for the architecture, but often on 8 bit
> micros it will be larger (since char typically provides an 8 bit int anyway.)

It's larger because an 8 bits can't represent the required range of values.
 
Regards,
 
   -=Dave
 


Time for vacation? WIN what you need. Enter Now! _______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list


_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Re: 24 bit Integer

by Steven Michalske :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry,

I though GCC supported the more of the PDP lines,   but its just the  
PDP-11 with it's 36bit words....

Steve

On Jul 30, 2008, at 8:54 PM, Weddington, Eric wrote:

>
>
>> -----Original Message-----
>> From:
>> avr-gcc-list-bounces+eweddington=cso.atmel.com@...
>> [mailto:avr-gcc-list-bounces+eweddington=cso.atmel.com@nongnu.
>> org] On Behalf Of Steven Michalske
>> Sent: Wednesday, July 30, 2008 8:38 PM
>> To: avr-gcc List
>> Subject: Re: [avr-gcc-list] 24 bit Integer
>>
>> what about a PDP 8 or PDP 15,  could we not code for it?
>> being 12 and 18 bit machines?
>>
>
> Does GCC have a target for the PDP-8 or PDP-15?
>
> And somehow I don't think that it relates to AVR GCC...



_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Re: 24 bit Integer

by Dave N6NZ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

PDP-11 is 16 bit words, byte addressed.  DEC-10 was 36 bit words.

-dave

Steven Michalske wrote:

> Sorry,
>
> I though GCC supported the more of the PDP lines,   but its just the
> PDP-11 with it's 36bit words....
>
> Steve
>
> On Jul 30, 2008, at 8:54 PM, Weddington, Eric wrote:
>
>>
>>
>>> -----Original Message-----
>>> From:
>>> avr-gcc-list-bounces+eweddington=cso.atmel.com@...
>>> [mailto:avr-gcc-list-bounces+eweddington=cso.atmel.com@nongnu.
>>> org] On Behalf Of Steven Michalske
>>> Sent: Wednesday, July 30, 2008 8:38 PM
>>> To: avr-gcc List
>>> Subject: Re: [avr-gcc-list] 24 bit Integer
>>>
>>> what about a PDP 8 or PDP 15,  could we not code for it?
>>> being 12 and 18 bit machines?
>>>
>>
>> Does GCC have a target for the PDP-8 or PDP-15?
>>
>> And somehow I don't think that it relates to AVR GCC...
>
>
>
> _______________________________________________
> AVR-GCC-list mailing list
> AVR-GCC-list@...
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
>



_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@...
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
LightInTheBox - Buy quality products at wholesale price