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

[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 07:11:35 +0100

> How should I re-word my bit test statement/expression, to cause the
> compiler to use these lovely SBRS/C instructions at last ?

Sorry for the noise  :-/
Why is it always AFTER I hit the 'send' button, that I suddenly get the
bright idea that stops me pulling my hair ??

I replaced the '&' operator with the more appropriate '&&' one.... works
much better... 5 instructions instead of 115 (3 + 6*18 + 4) for the
previous code.
So that's indeed about 20 times faster. Although I still don't get why
it can't just use one single SBRC/S instruction instead of these 4 cp or
cpc instructions... I guess I am still missing something in the bit test
department...

--
Vince

                if (address && 0x00040000)
    24ec:       21 15           cp      r18, r1
    24ee:       31 05           cpc     r19, r1
    24f0:       41 05           cpc     r20, r1
    24f2:       51 05           cpc     r21, r1
    24f4:       11 f0           breq    .+4             ; 0x24fa



>               if (address & 0x00040000)
>     24ec:     da 01           movw    r26, r20
>     24ee:     c9 01           movw    r24, r18
>     24f0:     72 e1           ldi     r23, 0x12       ; 18
>     24f2:     b6 95           lsr     r27
>     24f4:     a7 95           ror     r26
>     24f6:     97 95           ror     r25
>     24f8:     87 95           ror     r24
>     24fa:     7a 95           dec     r23
>     24fc:     d1 f7           brne    .-12            ; 0x24f2
>     24fe:     81 70           andi    r24, 0x01       ; 1
>     2500:     90 70           andi    r25, 0x00       ; 0
>     2502:     89 2b           or      r24, r25
>     2504:     11 f0           breq    .+4             ; 0x250a 114





reply via email to

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