Example:
procedure Timer1_OVF; org OVF1addr;
begin
Inc(CurScene);
if CurScene > 32 then CurScene:= 1;
end;
ASM Listing:
PUSH R0;PUSH R1;PUSH R3
PUSH R4;PUSH R5;PUSH R6
PUSH R7;PUSH R8;PUSH R9
PUSH R12;PUSH R15;PUSH R16
PUSH R17;PUSH R22;PUSH R28;PUSH R29
IN R28, SPL
IN R29, SPH
SBIW R28, 2
OUT SPL, R28
OUT SPH, R29
ADIW R28, 1
PUSH R30;PUSH R31;PUSH R27
IN R27, SREG
PUSH R27
;Inc(CurScene);
LDS R16, _CurScene+0
MOV R17, R16
SUBI R17, 255
STS _CurScene+0, R17
;if CurScene > 32 then CurScene:= 1;
LDI R16, 32
CP R16, R17
BRSH L_DMXSenderPro_Timer1_OVF80
L_Timer1_OVF247:
LDI R27, 1
STS _CurScene+0, R27
L_Timer1_OVF80:
;end;
L_endTimer1_OVF:
POP R27
OUT SREG, R27
POP R27;POP R31;POP R30
ADIW R28, 1
OUT SPL, R28
OUT SPH, R29
POP R29;POP R28;POP R22
POP R17;POP R16;POP R15
POP R12;POP R9;POP R8
POP R7;POP R6;POP R5
POP R4;POP R3;POP R1;POP R0
RETI
What for the superfluous code is generated so much??? After all registers R16, R17 well and manipulations with stack R27, R28, R29, R30, R31 (which are absolutely not necessary) are really used only!!! So are still added PUSH-POP for registers which are not used at all in interruption!!! Whether it is impossible to improve optimisation as the minimum quantity of steps in interruption is often necessary.
P.S. I use the translator :-(
What for superfluous PUSH POP in interruptions
Re: What for superfluous PUSH POP in interruptions
It is adviced that you download the latest beta version and then to try the test:
http://www.mikroe.com/forum/viewtopic.php?p=88309#88309
Thank you.
http://www.mikroe.com/forum/viewtopic.php?p=88309#88309
Thank you.
Simple Example:
program demo;
const
OVF0addr = 0x0009;
OVF1addr = 0x0008;
OVF2addr = 0x0004;
procedure Delay10us;
begin
Delay_us(10);
end;
procedure Delay100us;
begin
Delay_us(100);
end;
procedure Timer0_OVF; org OVF0addr;
begin
Delay100us;
end;
procedure Timer1_OVF; org OVF1addr;
begin
Delay10us;
end;
procedure Timer2_OVF; org OVF2addr;
begin
asm
nop;
end;
end;
begin
end.
Here that has noticed if in different interruptions different procedures that are caused superfluous registers R0-R15 are added and if in this case to cause identical that are not added. In the big project too most though anywhere these registers are not used.
In procedure Timer2_OVF in general anything superfluous should not be, and so much dust is added.
It would be desirable to add something of type such
{$R-}//Disable save Regs
procedure Timer2_OVF; org OVF2addr;
begin
end;
{$R +}//Enable save Regs.
And yourself to add necessary PUSH-POP and Save Stack.
program demo;
const
OVF0addr = 0x0009;
OVF1addr = 0x0008;
OVF2addr = 0x0004;
procedure Delay10us;
begin
Delay_us(10);
end;
procedure Delay100us;
begin
Delay_us(100);
end;
procedure Timer0_OVF; org OVF0addr;
begin
Delay100us;
end;
procedure Timer1_OVF; org OVF1addr;
begin
Delay10us;
end;
procedure Timer2_OVF; org OVF2addr;
begin
asm
nop;
end;
end;
begin
end.
Here that has noticed if in different interruptions different procedures that are caused superfluous registers R0-R15 are added and if in this case to cause identical that are not added. In the big project too most though anywhere these registers are not used.
In procedure Timer2_OVF in general anything superfluous should not be, and so much dust is added.
It would be desirable to add something of type such
{$R-}//Disable save Regs
procedure Timer2_OVF; org OVF2addr;
begin
end;
{$R +}//Enable save Regs.
And yourself to add necessary PUSH-POP and Save Stack.
Hi,
This is the code generated for the simple example you have provided above.
What huge (overhead) contex saving are we talking about? Please, provide us with whole example which will demonstrate the issue you are talking about.
Regarding letting user do the contex saving themselfs, we already have it in our to do list. It will be implemented in some of the feature releases.
This is the code generated for the simple example you have provided above.
Code: Select all
main:
LDI R27, 255
OUT SPL, R27
LDI R27, 16
OUT SPH, R27
L_endmain:
RJMP L_endmain
; end of _main
Prazan_Delay10us:
;Prazan.mpas,9 :: begin
;Prazan.mpas,10 :: Delay_us(10);
LDI R16, 26
DEC R16
BRNE $-1
NOP
NOP
;Prazan.mpas,11 :: end;
L_endDelay10us:
0x00C6 0x9508 RET
; end of Prazan_Delay10us
Prazan_Timer1_OVF:
PUSH R30
PUSH R31
PUSH R27
IN R27, SREG
PUSH R27
;Prazan.mpas,24 :: begin
;Prazan.mpas,25 :: Delay10us;
RCALL Prazan_Delay10us+0
;Prazan.mpas,26 :: end;
L_endTimer1_OVF:
POP R27
OUT SREG, R27
POP R27
POP R31
POP R30
RETI
; end of Prazan_Timer1_OVF
Prazan_Timer2_OVF:
PUSH R30
PUSH R31
PUSH R27
IN R27, SREG
PUSH R27
;Prazan.mpas,29 :: begin
;Prazan.mpas,31 :: nop;
NOP
;Prazan.mpas,33 :: end;
L_endTimer2_OVF:
POP R27
OUT SREG, R27
POP R27
POP R31
POP R30
RETI
Regarding letting user do the contex saving themselfs, we already have it in our to do list. It will be implemented in some of the feature releases.