(Assembler) PIC Interrupt Context Save and Restore

This code is used to save and restore the context registers of a PIC18F device before executing an interrupt service routine. FSR0 only needs to be saved

  1. ISR:
  2. ; Save processor context
  3. movwf   wSave, 0
  4. movff   STATUS, statSave
  5. movff   BSR, bsrSave
  6.  
  7. ; Save FSR0
  8. movff   FSR0L, fsr0lSave
  9. movff   FSR0H, fsr0hSave
  10.  
  11. ; Insert code here
  12.  
  13. End_Isr:
  14. ; Restore FSR0
  15. movff   fsr0lSave, FSR0L
  16. movff   fsr0hSave, FSR0H
  17.  
  18. ; Restore processor context and return
  19. movff   bsrSave, BSR
  20. movf    wSave, w, 0
  21. movff   statSave, STATUS
  22. retfie  0
This entry was posted in Assembler and tagged , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Why ask?

  • Advertisement

  • Categories