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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] avr-gcc bug (Win)


From: Mike Jones
Subject: Re: [avr-gcc-list] avr-gcc bug (Win)
Date: Tue, 27 Feb 2001 21:48:10 -0600

here is what I get using a slightly modified makefile from Volker's test
suite (uses -o3) and the latest windows32 version downloaded from
http://combio.de/avr

Notice that R28 and R29 have apparently swapped function and in line 92 it
uses "brge" instead of "brlt". Otherwise they look the same.

Obviously, this code is not generated by the same version of the compiler. I
did remove lots of extraneous lines of AS source to make the code stand out
better, including the C source that was inserted as comments.


   1                 .file "test.c"
   2                 .arch at90s8515
   3                __SREG__ = 0x3f
   4                __SP_H__ = 0x3e
   5                __SP_L__ = 0x3d
   6                __tmp_reg__ = 0
   7                __zero_reg__ = 1
   8                _PC_ = 2
  40                .LM1:
  44                .LM2:
  45 0000 80E8        ldi r24,lo8(128)
  46 0002 90E0        ldi r25,hi8(128)
  48                .LM3:
  53                .Lfe1:
  60                main:
  62                .LM4:
  64 0006 C0E0        ldi r28,lo8(__stack - 0)
  65 0008 D0E0        ldi r29,hi8(__stack - 0)
  66 000a DEBF        out __SP_H__,r29
  67 000c CDBF        out __SP_L__,r28
  70                .LM5:
  71                .LBB2:
  72 000e 80E0        ldi r24,lo8(0)
  73 0010 F7DF        rcall mycall
  74 0012 C82F        mov r28,r24
  76                .LM6:
  77 0014 81E0        ldi r24,lo8(1)
  78 0016 F4DF        rcall mycall
  79 0018 D82F        mov r29,r24
  80                .L11:
  82                .LM7:
  83 001a CC23        tst r28
  84 001c F1F3        breq .L11
  86                .LM8:
  87 001e 80E0        ldi r24,lo8(0)
  88 0020 EFDF        rcall mycall
  90                .LM9:
  91 0022 8823        tst r24
  92 0024 1CF4        brge .L12
  94                .LM10:
  95 0026 DD23        tst r29
  96 0028 21F4        brne .L13
  97 002a F7CF        rjmp .L11
  99                .LM11:
 100                .L12:
 101 002c 81E0        ldi r24,lo8(1)
 102 002e E8DF        rcall mycall
 103 0030 F4CF        rjmp .L11
 105                .LM12:
 106                .L13:
 107 0032 82E0        ldi r24,lo8(2)
 108 0034 E5DF        rcall mycall
 110                .LM13:
 111 0036 F1CF        rjmp .L11
 112                .LBE2:
 114                __stop_progIi__:
 115 0038 FFCF        rjmp __stop_progIi__

Mike

----- Original Message -----
From: "Denis Chertykov" <address@hidden>
To: "Peter Bosscha" <address@hidden>
Cc: <address@hidden>
Sent: Tuesday, February 27, 2001 3:25 PM
Subject: Re: [avr-gcc-list] avr-gcc bug (Win)


> "Peter Bosscha" <address@hidden> writes:
>
> > Content-type: text/plain ; charset = US-ASCII
> >
> > Hi,
> >
> > Found a bug in branch logic together with the BRGE instruction.
> > I'm using avr-libc-20010211 and -O2 and -Os give the same (erroneous)
result.
> > Tried to simplify this as much as possible so the code is a joke.
> >
> > Have a look at the following:
> >
> > unsigned char mycall(unsigned char parm)
> > {
> >  return 0x80;
> > }
> >
> > int main(void)
> > {
> > unsigned char i,a,b;
> >
> >  a=mycall(0);
> >  b=mycall(1);
> >  do {
> >   if (a) {
> >    i = mycall(0);
> >    if (i & 0x80) {
> >     mycall(1);
> >    } else {
> >     if (b) {
> >      mycall(2);
> >     }
> >    }
> >   }
> >  } while(1);
> >  return 1;
> > }
> >
> > In this example the jump at if (i & 0x80) goes the wrong way.
>
> Point me to a wrong place in generated code.
> My avr-gcc (CVS version) generates:
>
>
> .global main
> .type main,@function
> main:
> /* prologue: frame size=0 */
> ldi r28,lo8(__stack - 0)
> ldi r29,hi8(__stack - 0)
> out __SP_H__,r29
> out __SP_L__,r28
> /* prologue end (size=4) */
> ldi r24,lo8(0)
> rcall mycall
> mov r29,r24
> ldi r24,lo8(1)
> rcall mycall
> mov r28,r24
> .L11:
> tst r29
> breq .L11
> ldi r24,lo8(0)
> rcall mycall
> tst r24
> brlt .L12
> tst r28
> brne .L13
> rjmp .L11
> .L12:
> ldi r24,lo8(1)
> rcall mycall
> rjmp .L11
> .L13:
> ldi r24,lo8(2)
> rcall mycall
> rjmp .L11
> /* epilogue: frame size=0 */
> __stop_progIi__:
> rjmp __stop_progIi__
> /* epilogue end (size=1) */
> /* function main size 27 (22) */
>
> > So ... 2 questions:
> >
> > - is everyone else getting this too ?
>
> Few weeks ago I have corrected such bug in GCC CVS.
> I can't understand why I read bug reports about it.
>
> > - if so, where to report this ?
>
> This mailing list si a right place.
>
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://avr.jpk.co.nz/mailman/listinfo/avr-gcc-list
>




reply via email to

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