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

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

Re: [avr-gcc-list] gcc binary


From: Yura Galayda
Subject: Re: [avr-gcc-list] gcc binary
Date: Fri, 05 Mar 2004 19:42:19 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 MultiZilla/1.6.0.0e

<x-flowed>
Yura Galayda wrote:

      Or try can another version code:

#define BIN__N(x) (x) | x>>3 | x>>6 | x>>9
#define BIN__B(x) (x) & 0xf | (x)>>12 & 0xf0

#define BIN8(v) (BIN__B(BIN__N(0x##v)))



      Why not use macros, for example:

#define BIN8(x) BIN___(0##x)

#define BIN___(x)                                        \
       (                                                \
       ((x / 01ul) % 010)*(2>>1) +                      \
       ((x / 010ul) % 010)*(2<<0) +                     \
       ((x / 0100ul) % 010)*(2<<1) +                    \
       ((x / 01000ul) % 010)*(2<<2) +                   \
       ((x / 010000ul) % 010)*(2<<3) +                  \
       ((x / 0100000ul) % 010)*(2<<4) +                 \
       ((x / 01000000ul) % 010)*(2<<5) +                \
       ((x / 010000000ul) % 010)*(2<<6)                 \
       )

#define BIN16(x1,x2) \
           ((BIN(x1)<<8)+BIN(x2))

#define BIN24(x1,x2,x3) \
           ((BIN(x1)<<16)+(BIN(x2)<<8)+BIN(x3))

#define BIN32(x1,x2,x3,x4) \
           ((BIN(x1)<<24)+(BIN(x2)<<16)+(BIN(x3)<<8)+BIN(x4))


char  i1 = BIN8  (00101010);
short i2 = BIN16(10110110,11101110);
long  i3 = BIN24(10110111,00010111,01000110);
long i4 = BIN32(11101101,01101000,01010010,10111100);
Erik Christiansen wrote:

On Wed, Mar 03, 2004 at 08:20:57PM +0100, Joerg Wunsch wrote:
It seems to be quite common among µC C compilers.  Unlike the PORTB.0
notation where I don't see how this would ever fit at all into legal C
syntax, I can imagine that 0b is a perferctly legal vendor extension
for a compiler.


It's also perfectly legal for avr-as (OK, that's binutils, but gcc is
nothing without it):

ldi    r16,0b10111111

Overcoming the compiler deficiency seems attractive. Portability is a
bit of a worry, though. I wonder if the 'C' world could be educated, in
time?

Just curious, I've once made a patch for GCC that implements it.  This
was merely intented to be a proof of concept.  Does anyone
incidentally know whether this feature might have already been
proposed (and perhaps put down) to the GCC folks?  If not, do people
feel I should submit that patch?


In case anyone is interested:

http://www.sax.de/~joerg/gcc-0b.patch



Interested enough to take a copy for future reference. (When this
first project is delivered, I'll take a look at the compiler. :)

Thanks Jörg.

Erik

_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list





--
------------
Yuri Galayda at EIC Vector R&D Department       address@hidden
Fax or VoiceMail                                +1 206 202 4455
PGP public key available


_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list

</x-flowed>

reply via email to

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