RAM handling in ISRs

Hi all,

I’m a bit confused about the handling of the FSR0 and FSR2 pointer during the ISR’s - is it saved when entering and restored on exiting the ISR, or carried into the ISR and lost on exit or…?

From the words of the Boss:

Following registers are dedicated for mainprograms, they will not be automatically saved before an interrupt call:

TMP1…TMP5 and FSR0

Following registers are dedicated for interrupt service routines, they shouldn’t be used by mainprograms:

IRQ_TMP1…IRQ_TMP5 and FSR2

Following registers are stored automatically by the interrupt handler before a hook will be called, and they will be restored before the interrupt will be finished - therefore they can be used by the mainprogram and by ISRs without conflicts:

FSR1, TBLPTRL, TBLPTRH, TABLAT, MIOS_PARAMETER1…MIOS_PARAMETER3

And then on the ram handling doc available on the download page at ucapps.de:

Question from Duggle:

> Does FSR2 get saved and restored in the ISRs?

> (if not then it can’t be used in user routines without disabling interrupts)?

> MIOS routines use FSR1 so if I use FSR1 completely in-between MIOS calls it

> should be ok? (MIOS may destroy FSR1’s content)

> Are there any dangers of using FSR0? (It gets used by main, are there

> any user hooks that should restore its content  for use by main?

Answer:

All FSRs (FSR0, FSR1 and FSR2) as well as TBLPTR[LH], TABLAT and

MIOS_PARAMETER[123] are stored by the interrupt handler.

Yes, you can use FSR1 in between MIOS calles in your main program and in

interrupt service routines w/o problems.

What does happen to FSR0 and FSR2? Am I missing something?

Since MIOS V1.8, FSR2 is saved as well, and FSR0 is saved by the C wrapper

Most of the older docs are inconsistent in the meantime, I know… biggest problem is, that all ISR related comments in the main.asm file are not correct anymore… just ignore it

Best Regards, Thorsten.

Thanks TK :slight_smile: