New Optimiser Feature

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

New Optimiser Feature

 · 
Posted: 22.01.2018 - 20:05  ·  #1
For those of you writing interrupt procedures the latest optimiser will check register save and restore. Not only will it remove saves you don't need, but it will also add in any that you missed.

With thanks to Miparo who suggested and tested this latest feature.
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: New Optimiser Feature

 · 
Posted: 31.01.2018 - 14:37  ·  #2
Nice touch. Thank you!
Lschreyer
Schreiberling
Avatar
Gender: n/a
Posts: 526
Registered: 02 / 2007
Subject:

Re: New Optimiser Feature

 · 
Posted: 06.03.2018 - 18:52  ·  #3
I am not sure if this is correct, I tested it with an old project and looked in the .asm file.

Code

Interrupt PortF_INT0;
begin
 PUSHALLREGS;
 toggle(led1);
  HandleEncoderInt_new;
  HandleEncoderInt;
  POPALLREGS;
end;


Gives this:(At the end of all register saving code there is still a call to SYSTEM.PUSHALLREGS, is that ok? It seems as it does it twice now..

Code

testproj.INTERRUPT_TCD1_INTOVF:
                        PUSH      _ACCGLO
                        PUSH      _ACCGHI
                        PUSH      _ACCHLO
                        PUSH      _ACCHHI
                        PUSH      $_SAVERET
                        PUSH      $_SAVERET1
                        PUSH      $_SAVERET2
                        PUSH      FLAGS
                        PUSH      FLAGS2
                        PUSH      _SYSTFLAGS
                        PUSH      _BEEPTIMER
                        PUSH      R11
                        PUSH      R12
                        PUSH      R13
                        PUSH      R14
                        PUSH      R15
                        PUSH      _ACCB
                        PUSH      _ACCA
                        PUSH      _ACCALO
                        PUSH      _ACCAHI
                        PUSH      _ACCDLO
                        PUSH      _ACCDHI
                        PUSH      _ACCELO
                        PUSH      _ACCEHI
                        PUSH      _ACCFLO
                        PUSH      _ACCFHI
                        PUSH      _ACCBLO
                        PUSH      _ACCBHI
                        PUSH      _FRAMEPTR
                        PUSH      _FPTRHI
                        PUSH      _ACCCLO
                        PUSH      _ACCCHI
                        IN        _ACCBHI, SREG
                        PUSH      _ACCBHI
                        .RETURNS   -1
                        .BLOCK    1915
                        .LINE     1916
                        LDS       _ACCA, testproj.ENABLE_OFFLINE_DRIVE
                        TST       _ACCA
                        .BRANCH   3, testproj._L1934
                        BREQ      testproj._L1934
                        .BLOCK    1916
                        .LINE     1917
                         CALL      SYSTEM.PUSHALLREGS

                        .LINE     1919
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1372
Registered: 03 / 2005
Subject:

Re: New Optimiser Feature

 · 
Posted: 06.03.2018 - 21:13  ·  #4
You are right. I cater for the case when PushAllRegs is in the system area (where it normally is) but not where it is handled manually in user code like this. If you send me the asm and dsm files via pm I will look into it.
Lschreyer
Schreiberling
Avatar
Gender: n/a
Posts: 526
Registered: 02 / 2007
Subject:

Re: New Optimiser Feature

 · 
Posted: 07.03.2018 - 08:41  ·  #5
Maybe I miss something here. As I understood the manual I need to add pusallregs/popallregs if I need the registers saved in the int service routine.
Therefore I added that to my int routines. Is there a better way to do it?
Merlin
Administrator
Avatar
Gender:
Age: 24
Posts: 1372
Registered: 03 / 2005
Subject:

Re: New Optimiser Feature

 · 
Posted: 07.03.2018 - 09:34  ·  #6
If you are using the optimiser, you don't need to do anything. The optimiser will add the registers saves and restores for you, and only for the registers you are actually using. Also I can't see enough code to tell, but depending on what switches you are using the system might be doing the same as well, meaning you are potentially saving the registers 3 times! (Although that is not strictly true, because if the system does it I remove duplicates). So no, you don't need to add these calls, and unless you use special directives like {$NOREGSAVE} you don't need to do it even if you are not using the optimiser.

You used to need to do it a long time ago but that has not been the case for some years.
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: 15 · Cache Hits: 14   104   118 · Page-Gen-Time: 0.021247s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI