Interrupt local variables overlayed?[OK]

Beta Testing discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Interrupt local variables overlayed?[OK]

#1 Post by Dany » 03 Dec 2014 16:15

Answered by Janni:
This should not be a problem if respective internal registers (R5,6,7) are saved and restored in ISR. You could check this in *.lst file.
Normally, saving context includes all internal registers used both in ISR and main code. And optimizer may replace local variables with internal registers in ISR, just like in any routine - the only difference is that ISR requires restoring previous values of internal registers.
and Janni was of course right: There is no problem, the values of registers R0..R6 are saved. I should have seen that... :oops: :oops:

Original post:

Hi mE people,

I saw in a project (not mine) that local variables of the interrupt routine are overlayed with some other variables. I was under the impression that was impossible (meaning: should not be allowed).

Apparently, sometines mP for PIC v.6.4.0. optimiser decides that it can be done, see below address 4,5 and 6.
Capture3-12-2014-16.03.05.jpg
Capture3-12-2014-16.03.05.jpg (161.61 KiB) Viewed 2829 times
The source code looks like this:

Code: Select all

procedure interrupt;
var
  enc, bbb  : byte;
  tas       : byte;
  
begin
   ...
end;
I can not reproduce this behaviour in testcode, and I can not publish the code that gives the phenomenon. :oops:
The PIC used in the problem project is P18F67J60.

Thanks for investigating.
Last edited by Dany on 03 Dec 2014 19:29, edited 4 times in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Interrupt local variables overlayed?

#2 Post by janni » 03 Dec 2014 16:31

Hi Dany,

This should not be a problem if respective internal registers (R5,6,7) are saved and restored in ISR. You could check this in *.lst file.

Normally, saving context includes all internal registers used both in ISR and main code. And optimizer may replace local variables with internal registers in ISR, just like in any routine - the only difference is that ISR requires restoring previous values of internal registers.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Interrupt local variables overlayed?

#3 Post by Dany » 03 Dec 2014 19:21

janni wrote:Hi Dany,

This should not be a problem if respective internal registers (R5,6,7) are saved and restored in ISR. You could check this in *.lst file.

Normally, saving context includes all internal registers used both in ISR and main code. And optimizer may replace local variables with internal registers in ISR, just like in any routine - the only difference is that ISR requires restoring previous values of internal registers.
Thanks Janni,
You are indeed right, there is no problem, the values of registers R0..R6 are saved. I should have seen that... :oops: :oops:

I am relieved because I did not know why the project worked while some variables were (I assumed) overwritten during interrupts... :shock:
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroPascal PRO for PIC Beta Testing”