[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] mass stupidity with registers and longs
From: |
Peter Bosscha |
Subject: |
Re: [avr-gcc-list] mass stupidity with registers and longs |
Date: |
Fri, 14 Jan 2005 07:35:23 +0200 |
Hi,
I've been using the following (don't have 3.4.1, but should simply work
?)
typedef union {
long l;
struct {
unsigned char byte0,byte1,byte2,byte3;
};
} longbytes;
----
longbytes ul;
unsigned char a,b,c,d;
ul.l = 0;
ul.byte0 = d;
ul.byte1 = a;
etc...
Advantage is also that this seems to produce the most efficient code.
---
Peter Bosscha
>>> Curtis Maloney <address@hidden> 14/01/2005 06:51:59 >>>
I give up. I've been trying to shift 4 chars into an unsigned long,
but can't
stop GCC 3.4.1 (what's shipped with the latest WinAVR) from sign
extending
values, let alone producing sane code.
I've tried -Os, -O2, -O3, with and without -fnew-ra... the asm varies,
but is
generaly crap.
now, if I have:
extern char a[4];
unsigned long ul;
ul = ( (unsigned)a[0] << 8 ) | (unsigned)a[1];
why would it be sign extending a[0] and a[1] when they're cast to
unsigneds?
And then why doesn't the code optimiser see to just mov rX, a[1]; mov
rX+1,a[0] ?
I tried casts on casts on casts... everything I could think of to get
better
code, and it just did not improve.
Am I missing something, or do I just need to get gcc 3.4.3? If so, is
anyone
lurking here involved with WinAVR, and can tell me when the next update
might
happen?
--
Curtis Maloney
_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list
- [avr-gcc-list] mass stupidity with registers and longs, Curtis Maloney, 2005/01/13
- Re: [avr-gcc-list] mass stupidity with registers and longs, James Washer, 2005/01/14
- RE: [avr-gcc-list] mass stupidity with registers and longs, Ben Mann, 2005/01/14
- Re: [avr-gcc-list] mass stupidity with registers and longs, Russell Shaw, 2005/01/14
- Re: [avr-gcc-list] mass stupidity with registers and longs, E. Weddington, 2005/01/14
- Re: [avr-gcc-list] mass stupidity with registers and longs, David Gay, 2005/01/17
- Re: [avr-gcc-list] mass stupidity with registers and longs,
Peter Bosscha <=