[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-b
From: |
Vincent Trouilliez |
Subject: |
Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ? |
Date: |
Fri, 04 Nov 2005 13:01:02 +0100 |
On Fri, 2005-11-04 at 10:17 +0100, Alex Wenger wrote:
> Him
>
> Vincent Trouilliez schrieb:
> > Thank you very much Ian, your code is highly efficient, and does work
> > perfectly, unlike && or &. :o) I am in heaven :
> >
> > temp = (address >> 16) & 0xFF;
> > 28bc: ca 01 movw r24, r20
> > 28be: aa 27 eor r26, r26
> > 28c0: bb 27 eor r27, r27
> > if (temp & 0x04)
> > 28c2: 82 ff sbrs r24, 2
> > 28c4: 02 c0 rjmp .+4 ; 0x28ca
> >
> > can't get any better than that really :o)))
>
> if you make temp unsigned char, it should be even better.
Yes I see what you mean, the two 'eor' instructions that clear the two
upper bytes.... The problem is that 'temp' IS declared as uint8_t, and I
have no idea why the compiler insists on clearing the upper bytes as if
it were casting it into a 32bit integer (then what about the second byte
in this case, should get cleared as well ?!). It's only testing a bit in
the first (and only) byte, r24, so I don't understand why it care for
upper bytes at all. I tried to reword the statement a bit:
temp = (uint8_t) (address >> 16) 0xFF;
,as well as change optimisation flags, but it really insists on clearing
these two bytes. God knows why. I guess it's doing something very subtle
that escapes me...
--
Vince
- Re: [avr-gcc-list] How to (efficeiently !!!) test abitwithinamulti-byte intege, (continued)
- Re: [avr-gcc-list] How to (efficeiently !!!) testabitwithinamulti-byte intege, Dave Hansen, 2005/11/07
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bitwithinamulti-byte intege, Vincent Trouilliez, 2005/11/05
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bitwithinamulti-byte intege, David Kelly, 2005/11/05
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bitwithinamulti-byte intege, Vincent Trouilliez, 2005/11/05
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within amulti-byte integer ?, Derric Tubbs, 2005/11/04
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?, Alex Wenger, 2005/11/04
- Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?,
Vincent Trouilliez <=
Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?, Bernard Fouché, 2005/11/04
Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?, Bernard Fouché, 2005/11/04
Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?, Vincent Trouilliez, 2005/11/05
Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within a multi-byte integer ?, David Kelly, 2005/11/05
RE: [avr-gcc-list] How to (efficeiently !!!) test a bit within amulti-byte integer ?, Niklas Lövgren, 2005/11/05
Re: [avr-gcc-list] How to (efficeiently !!!) test a bit within amulti-byte integer ?, Eric Weddington, 2005/11/08
RE: [avr-gcc-list] How to (efficeiently !!!) test a bit withinamulti-byte integer ?, Niklas Lövgren, 2005/11/09