avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] 24 bit Integer


From: David Kelly
Subject: Re: [avr-gcc-list] 24 bit Integer
Date: Mon, 14 Jul 2008 10:03:39 -0500
User-agent: Mutt/1.4.2.3i

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, address@hidden
========================================================================
Whom computers would destroy, they must first drive mad.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]