[avr-gcc-list] tool chain bug (fwd)

Alan Modra amodra@bigpond.net.au
Thu Sep 26 04:37:00 GMT 2002


On Wed, Sep 25, 2002 at 08:42:59PM -0700, Theodore A. Roth wrote:
> [troth@bozoland messy]$ cat mm.s
>         .arch atmega128
> __SREG__ = 0x3f
> __SP_H__ = 0x3e
> __SP_L__ = 0x3d
> __tmp_reg__ = 0
> __zero_reg__ = 1
> _PC_ = 2
> .Lfoo:
>         dec r24
>         brne _PC_-4
> .Lbar:
>         dec r24
>         brne .Lbar
> .Lloop:
>         rjmp .Lloop
> 
> Running this through gas with your patch yields this:
> 
> 00000000 <.text>:
>    0:   8a 95           dec     r24
>    2:   e9 f7           brne    .-6             ; 0xfffffffe
>    4:   8a 95           dec     r24
>    6:   f1 f7           brne    .-4             ; 0x4
>    8:   ff cf           rjmp    .-2             ; 0x8
> 
> line "2:" should match line "6:".

Why?  Or more specifically, what is the meaning of "brne -2"?  The
fact that older avr gas assembled this differently doesn't mean much.
I reckon the old behaviour was wrong, and that "brne -2" ought to
branch to address -2.  If you really want a pc relative branch,
write "brne .-4"

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list