2

I have not been able to find any information as to whether the MC68000 preserves its status register / CCR during external interrupts. I imagine it would be an issue if the CPU were to interrupt immediately before a conditional branch, and the interrupt modifies the CCR. Right now my interrupt code looks like this:

            ORG     $110000   ; Location of IPL6 vector
IPL6        MOVE.W  SR, -(SP) ; Is this line necessary?
            MOVE.L  D0, -(SP)
            ; Perform interrupt tasks here
            MOVE.L  (SP)+, D0
            MOVE.W  (SP)+, SR ; Is this line necessary?
            RTE               ; Return

I'm wondering if the indicated lines that push/pop the SR from the stack are required, or if the CPU automatically saves and restores the SR during interrupts.

cjgriscom
  • 176
  • 1
  • 12

2 Answers2

6

Yes, the CPU does store the status register on interrupt. Logically this is needed or otherwise issues like you mentioned would happen.

On page 6-84 of MOTOROLA M68000 FAMILY Programmer’s Reference Manual the RTE command shows that it restores SR among other registers so it has to have been stored previously.

Sami Kuhmonen
  • 30,146
  • 9
  • 61
  • 74
1

Your question is actually stated in a bit of an unlucky way because you don't state by whom (CPU or code):

Yes, the CCR needs to be preserved during interrupts (for obvious reasons that you have stated).

But no, it doesn't need to be explicitly preserved by the programmer (like it's unnecessarily done in your example), because the CPU does it automatically when it serves an interrupt.

tofro
  • 5,640
  • 14
  • 31