This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

A question about context switching

Hello,
There is an issue related to context switches that I do not understand.
I have written the most simple interrupt handler:

void foo() interrupt 0x20 using f_regs
{
}

The generated assembly code was as follows:

; FUNCTION foo (BEGIN RMASK = @0x4000)
; SOURCE LINE # 11
0000 F6F00000 R MOV f_regs,R0
0004 C60800C0 R SCXT CP,#f_regs
0008 CC00 NOP
; SOURCE LINE # 13
000A FC08 POP CP
000C FB88 RETI
; FUNCTION foo (END RMASK = @0x4000)

The bank switch seems to ignore the CPU registers that are not part of a register bank (MDL, PSW and so forth). What is happening here? Why is this a valid context switch?

Kind regards,
Tamir Michael

  • MDL is not saved because no multiplication or division takes place in the ISR. If you add multiplication or division then the compiler should save and restore MDL and related registers. There is no need to save PSW either, as far as I can tell.
    Actually, the bank switch could have been optimized out as well, since there is no code in the function.

    Best regards,
    - mike

  • "the bank switch could have been optimized out as well, since there is no code in the function"

    Ah that old chestnut - Beware the Trivial Test-Case! ;-)