Re: [AVR-Chat] Arrays and pointers in GCC
2009-01-12 by subscriptions@aeolusdevelopment.com
Original Message:
-----------------
David VanHorn wrote
>> I share your pain when you look at what the compiler's done, compared to
>> how you can do it in asm. You just have to breathe deeply and let it go.
>> If you're really strapped for execution time, you can write bits of it
>> in asm.
>
>And they told me and told me that C is can generate code that's "just
>as good" as a human..
>I thought they meant some non-random human...
Depending on architecture, compiler and human, the human can produce better
code over a 'short' stretch. The compiler's advantage is over longer
stretches, more complex code and architectures.
>> Don't even think about trying to use part of a byte as a variable and
>> part for flags. You can do it, but it starts to negate all the reasons
>> for writing in C in the first place.
>
>Why?
>
>I might be using the wrong terms here, but it seems to me like just
>another sort of struct.
Right terms, think of bit fields.
struct {
unsigned char index : 3;
unsigned char type : 5;
} bfld;
bfld.index++; /* increments and wraps index */
Key questions,
does GCC allow unsigned char in this context? It's a common extension.
does GCC allocate a single byte in this context?
Robert
--------------------------------------------------------------------
mail2web - Check your email from the web at
http://link.mail2web.com/mail2web