[BUG REPORT] Fehler beim Optimizer

  • 1
  • 2
  • 3
  • Page 2 of 3
Thomas.AC
Benutzer
Avatar
Gender: n/a
Age: 43
Posts: 308
Registered: 07 / 2013
Subject:

Re: [BUG REPORT] Fehler beim Optimizer

 · 
Posted: 23.02.2015 - 17:12  ·  #9
I possess real Hardware, which works fine without optimization.

I did real debugging with real Hardware and I used the simulator.

There were no differences.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: [BUG REPORT] Fehler beim Optimizer

 · 
Posted: 23.02.2015 - 17:40  ·  #10
Hello Thomas,

this not clear for me.
Did the real hardware work ok, results were ok?

rolf
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: [BUG REPORT] Fehler beim Optimizer

 · 
Posted: 23.02.2015 - 17:50  ·  #11
OK Thomas, thank you for this.

Do you have a serial port or LCD to display the global value after the function is called, just to eliminate the simulator altogether?

If not I will see if I can rig something up.

Many thanks for your time.
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: [BUG REPORT] Fehler beim Optimizer

 · 
Posted: 23.02.2015 - 18:34  ·  #12
Hello Merlin and Thomas,

with the optimiser the problem happens here:

endcase;
textbuffer := filename;


for some (for me unknown) reasons the optimiser seems
to provide a wrong Frame offset for the local source string "FileName".
When I take a look into the RAM Window before this assignment it shows:
Pict_1
After this it shows:
Pict_2
This is because the register register (R30, R31) is loaded with the wrong
address, $21A0 instead of $219D, so the whole string block transfer fails.

Here we can see the differences in DSM:
Code
                        .FRAME  6
                        MOVW      _ACCCLO, _FRAMEPTR
                        ADIW      _ACCCLO, 000008h
                        CALL      SYSTEM.StrVar2Str
....
                        .FRAME  6
                        MOVW      _ACCCLO, _FRAMEPTR
                        ADIW      _ACCCLO, 000008h
                        CALL      SYSTEM.StrVar2Str

and this is in the optimised ASM:
Code
                        .FRAME    3
                        MOVW      _ACCCLO, _FRAMEPTR
                        ADIW      _ACCCLO, 000005h
                        RCALL     SYSTEM.StrVar2Str
...
                        .FRAME    6
                        MOVW      _ACCCLO, _FRAMEPTR
                        ADIW      _ACCCLO, 000008h
                        RCALL     SYSTEM.StrVar2Str

The second .Frame directive seems to be wrong.
The resulting ASM code should be:
Code
                        .FRAME    3
                        MOVW      _ACCCLO, _FRAMEPTR
                        ADIW      _ACCCLO, 000005h
                        RCALL     SYSTEM.StrVar2Str

With .Frame 3 and offset 05h it works.

Sorry Merlin, this is a problem of the Optimiser.

rolf
Attachments
[BUG REPORT] Fehler beim Optimizer
Filename: Pict_3.jpg
Filesize: 53.14 KB
Title:
Download counter: 80
[BUG REPORT] Fehler beim Optimizer
Filename: Pict_2.jpg
Filesize: 26.88 KB
Title:
Download counter: 85
[BUG REPORT] Fehler beim Optimizer
Filename: Pict_1.jpg
Filesize: 26.94 KB
Title:
Download counter: 85
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: [BUG REPORT] Fehler beim Optimizer

 · 
Posted: 23.02.2015 - 22:20  ·  #13
Thanks for your help Rolf.
Thomas.AC
Benutzer
Avatar
Gender: n/a
Age: 43
Posts: 308
Registered: 07 / 2013
Subject:

Re: [BUG REPORT] Fehler beim Optimizer

 · 
Posted: 24.02.2015 - 08:17  ·  #14
Hello Rolf and Merlin,

Thank for your effort!
I write text to sd Card. Text is cryptic with optimisation. as you have found out the optimiser is probably responsible for this.
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: [BUG REPORT] Fehler beim Optimizer

 · 
Posted: 24.02.2015 - 11:14  ·  #15
Thank you gentlemen for your help. I have now isolated the issue and should have it resolved today.

The problem for the optimiser was the following block of code

Code
audioplayer._L0016:
audioplayer._L0014:
                        .BLOCK    46
                        .LINE     46
                        LDI       _ACCA, 000h
                        ADIW      _FRAMEPTR, 3
                        .BRANCH   20,audioplayer.stimu_X
                        JMP       audioplayer.stimu_X
                        .ENDBLOCK 47
                        .BRANCH   20,audioplayer._L0013
                        JMP       audioplayer._L0013

The second jump never gets reached, but the optimiser remembered the state of the frame as if it had been reached. When it later found line 13 it restored the the frame to these values which were incorrect.

So 13 is unlucky for some :-)

Thomas, do you want the fix or will you wait for the next release of the compiler?
Thomas.AC
Benutzer
Avatar
Gender: n/a
Age: 43
Posts: 308
Registered: 07 / 2013
Subject:

Re: [BUG REPORT] Fehler beim Optimizer

 · 
Posted: 24.02.2015 - 12:47  ·  #16
Glad to hear, that you could point out the misstake and that I could help to improve reliability of the optimiser.

I have sufficient Flash to compile without opti, do not need the fix at this moment.
  • 1
  • 2
  • 3
  • Page 2 of 3
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 16 · Cache Hits: 15   141   156 · Page-Gen-Time: 0.029175s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI