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!
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!