Merlin error?

removed lines from asm

wsandor
Benutzer
Avatar
Gender: n/a
Age: 53
Posts: 21
Registered: 07 / 2012
Subject:

Merlin error?

 · 
Posted: 03.04.2018 - 14:18  ·  #1
Hi,

I use AVRCO ver 5.04.04, Optimiser Ver 3.2.12.0 and run to the following error:

Pascal source (part):

{$IDATA}
var
tms: Integer;
buzzerOffTime,
buzzer2OffTime: Integer;
buzzer, buzzer2: Boolean;

{--------------------------------------------------------------}
{ functions }

procedure OnSysTick;

begin
asm;
LDS _ACCCLO, %.TMS
LDS _ACCCHI, %.TMS+1
ADIW _ACCCLO, 1
STS %.TMS, _ACCCLO
STS %.TMS+1, _ACCCHI
LDS _ACCB, %.BuzzerOffTime
LDS _ACCA, %.BuzzerOffTime+1
SUB _ACCB, _ACCCLO
SBC _ACCA, _ACCCHI
BRPL nobuzzer
LDI _ACCA, 0
STS %.buzzer, _ACCA
nobuzzer:
LDS _ACCB, %.Buzzer2OffTime
LDS _ACCA, %.Buzzer2OffTime+1
SUB _ACCB, _ACCCLO
SBC _ACCA, _ACCCHI
BRPL nobuzzer2
LDI _ACCA, 0
STS %.buzzer2, _ACCA
noBuzzer2:
endasm;
end;

If I compile it using the Optimiser, lines that use _ACCB in the first part áre removed:
Here is the generated asm: (lines in bold - 94 and 96 are missing! - but 102 and 104 is present)

.SYM tms, 00327h, 00004h, 3
merlintest.tms .EQU 327h ; var iData integer
.SYM buzzerOffTime, 00329h, 00004h, 3
merlintest.buzzerOffTime .EQU 329h ; var iData integer
.SYM buzzer2OffTime, 0032Bh, 00004h, 3
merlintest.buzzer2OffTime .EQU 32Bh ; var iData integer
.SYM buzzer, 0032Dh, 00003h, 3
merlintest.buzzer .EQU 32Dh ; var iData boolean
.SYM buzzer2, 0032Eh, 00003h, 3
merlintest.buzzer2 .EQU 32Eh ; var iData boolean
.FUNC OnSysTick, 00055h, 00020h
merlintest.OnSysTick:
.RETURNS 0
.BLOCK 87
.ASM
.LINE 89
LDS _ACCCLO, %.TMS
.LINE 90
LDS _ACCCHI, %.TMS+1
.LINE 91
ADIW _ACCCLO, 1
.LINE 92
STS %.TMS, _ACCCLO
.LINE 93
STS %.TMS+1, _ACCCHI
.LINE 95
LDS _ACCA, %.BuzzerOffTime+1
.LINE 97
SBC _ACCA, _ACCCHI
.LINE 98
BRPL nobuzzer
.LINE 99
LDI _ACCA, 0
.LINE 100
STS %.buzzer, _ACCA
nobuzzer:
.LINE 102
LDS _ACCB, %.Buzzer2OffTime
.LINE 103
LDS _ACCA, %.Buzzer2OffTime+1
.LINE 104
SUB _ACCB, _ACCCLO
.LINE 105
SBC _ACCA, _ACCCHI
.LINE 106
BRPL nobuzzer2
.LINE 107
LDI _ACCA, 0
.LINE 108
STS %.buzzer2, _ACCA
noBuzzer2:
.endasm
.ENDBLOCK 111
.LINE 111
.BRANCH 19
RET
.ENDFUNC 111

I think that the optimiser thinks that the value in _ACCB is not used, however it is not the case, it is needed for the subtraction and the following compare.
How can I avoid it? (without turning off the optimization completly)
(If there is no second part - lines between nobuzzer and nobuzzer2 then the result is good - as it is good for this block)

Thanks in advance!
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Merlin error?

 · 
Posted: 03.04.2018 - 14:46  ·  #2
Sandor wow,
you are using a stone-aged version of the Opti, current is 3.5.6
I attach this one ad hope it will help you.

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

Re: Merlin error?

 · 
Posted: 03.04.2018 - 14:56  ·  #3
Hi Sandor.

If the problem persists with the latest version of optimiser, please supply asm and dsm files via pm and I will investigate.
wsandor
Benutzer
Avatar
Gender: n/a
Age: 53
Posts: 21
Registered: 07 / 2012
Subject:

Re: Merlin error?

 · 
Posted: 04.04.2018 - 17:10  ·  #4
Thanks for the new optimiser version.
For my test project the new version solved the problem, the lines aren't missing anymore. However with my original, full project the new optimezer throws an Access Violation error. So I can't really use it...
I attached a screenshot about the error.
Attachments
Merlin error?
Filename: Merlin_error.jpg
Filesize: 267.81 KB
Title:
Information: Error screenshot
Download counter: 84
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: Merlin error?

 · 
Posted: 04.04.2018 - 17:27  ·  #5
Please send asm and dsm files (zipped) via pm and I will check it out.
wsandor
Benutzer
Avatar
Gender: n/a
Age: 53
Posts: 21
Registered: 07 / 2012
Subject:

Re: Merlin error?

 · 
Posted: 04.04.2018 - 18:14  ·  #6
I sent you the PM with the asked files.
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1409
Registered: 03 / 2005
Subject:

Re: Merlin error?

 · 
Posted: 04.04.2018 - 23:20  ·  #7
Hi Sandor.

Thanks for your code.

The optimiser crashed due to a syntax error in your hand crafted assembly code. However, because the built in AVRCo assembler allows this syntax error, I have decided that the optimiser should also allow it and have sent you an update via pm. I have also sent the update to Rolf to be issued in the next release.
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   124   139 · Page-Gen-Time: 0.027436s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI