Shop OBEX P1 Docs P2 Docs Learn Events
Seeking Tips Converting from INTERRUPT to INTERRUPT NOPRESERVE — Parallax Forums

Seeking Tips Converting from INTERRUPT to INTERRUPT NOPRESERVE

YendorYendor Posts: 288
edited 2008-08-05 16:21 in General Discussion
I apologize if this is repeated in the forum (it's not coming back with any hits for INTERRUPT NOPRESERVE).


I'm needing to shave off a few cycles in my interrupt.

I'm trying to do some code optimization, but am tempted to use the NOPRESERVE feature.
·
I currently have some SX/B in the interrupt with some nested ·if..then.else statements that uses the __PARAM1 variable, like the following...

MOV FSR,MyVal                 ;  IF MyVal = 1 THEN
MOV __PARAM1,IND              
BANK $00                      
CJNE __PARAM1,#1,@i__ELSE_2   
;...etc

·And note that the asm code show it push and popping the parms before and after the interrupt code.
; save/preserve param1 and param2 

MOV FSR,#__INTPARAMFSR 

MOV IND,M 

INC FSR 
MOV IND,__PARAM1 

INC FSR 
MOV IND,__PARAM2 
;...__PARAM3...etc.
'interrupt code
;pop stack

Other than code optimization, upping the clock, and doubling the interrupt period/reducing the sampling rate of my interrupt, which may not work in my application, what would the 'pro' approach be in reducing the 'stack', and the interrupt clocks using INTERRUPT NOPRESERVE?·

Would it be to introduce·different global·variables to replace _PARAM1, or would it be to only preserve the variables the interrupt really needs to reuse ? e.g.·__INTPARAMFSR,·__PARAM1 in this case?

Many thanks!

Rodney



Post Edited (Yendor) : 8/4/2008 9:07:29 PM GMT

Comments

  • JonnyMacJonnyMac Posts: 9,215
    edited 2008-08-04 22:17
    If myVal was a global then the ISR wouldn't need indirect addressing; that might be an easy change. Or, you can borrow from SX/B (I do it a lot) and create your own "push" and "pop" code to protect the __PARAMx vars that might get used by the ISR:

    Set your ISR to NOPRESERVE and then use this at the beginning of the ISR:
    Push_Global:
      ASM
        MOV   FSR, #__INTPARAMFSR 
        MOV   IND, M 
        INC   FSR
        MOV   IND, __PARAM1
        BANK  $00
      ENDASM
    


    And this right before the RETURNINT:
    Pop_Global:
      ASM
        MOV   FSR, #__INTPARAMFSR
        MOV   M, IND
        INC   FSR
        MOV   __PARAM1, IND
        BANK  $00
      ENDASM
    
  • YendorYendor Posts: 288
    edited 2008-08-05 16:21
    Thanks for confirming Jon!
Sign In or Register to comment.