SPRAC71B February 2019 – October 2023
Interrupt functions (that is, the assembly function that performs the ISR) must save a number of registers. These registers include AR1H, AR0H, XT, and XAR4-XAR7. The following assembly code performs the proper context save and C environment fixing actions for devices without FPU32 support:
ASP ; [CPU_]
PUSH AR1H:AR0H ; [CPU_]
SPM 0 ; [CPU_]
MOVL *SP++,XT ; [CPU_]
MOVL *SP++,XAR4 ; [CPU_]
MOVL *SP++,XAR5 ; [CPU_]
MOVL *SP++,XAR6 ; [CPU_]
MOVL *SP++,XAR7 ; [CPU_]
CLRC PAGE0,OVM ; [CPU_]
CLRC AMODE ; [CPU_]
LCR #||call|| ; [CPU_] |3|
; call occurs [#||call||] ; [] |3|
MOVL XAR7,*--SP ; [CPU_]
MOVL XAR6,*--SP ; [CPU_]
MOVL XAR5,*--SP ; [CPU_]
MOVL XAR4,*--SP ; [CPU_]
MOVL XT,*--SP ; [CPU_]
POP AR1H:AR0H ; [CPU_]
NASP ; [CPU_]
IRET ; [CPU_]
The following assembly code performs the proper context save and C environment fixing actions for devices that do support FPU32:
ASP ; [CPU_]
PUSH RB ; [CPU_] x
PUSH AR1H:AR0H ; [CPU_]
MOVL *SP++,XT ; [CPU_]
MOVL *SP++,XAR4 ; [CPU_]
MOVL *SP++,XAR5 ; [CPU_]
MOVL *SP++,XAR6 ; [CPU_]
MOVL *SP++,XAR7 ; [CPU_]
MOV32 *SP++,STF ; [CPU_] x
MOV32 *SP++,R0H ; [CPU_]
MOV32 *SP++,R1H ; [CPU_]
MOV32 *SP++,R2H ; [CPU_]
MOV32 *SP++,R3H ; [CPU_]
SETFLG RNDF32=1, RNDF64=1 ; [CPU_]
SPM 0 ; [CPU_]
CLRC PAGE0,OVM ; [CPU_]
CLRC AMODE ; [CPU_]
LCR #||call|| ; [CPU_] |3|
; call occurs [#||call||] ; [] |3|
MOV32 R3H,*--SP ; [CPU_]
MOV32 R2H,*--SP ; [CPU_]
MOV32 R1H,*--SP ; [CPU_]
MOV32 R0H,*--SP ; [CPU_]
MOV32 STF,*--SP ; [CPU_]
MOVL XAR7,*--SP ; [CPU_]
MOVL XAR6,*--SP ; [CPU_]
MOVL XAR5,*--SP ; [CPU_]
MOVL XAR4,*--SP ; [CPU_]
MOVL XT,*--SP ; [CPU_]
POP AR1H:AR0H ; [CPU_]
POP RB ; [CPU_]
NASP ; [CPU_]
IRET ; [CPU_]
Interrupts push the SR and PC registers onto the stack and branch to an interrupt handler. To return from an interrupt function, the function must execute the special instruction IRET, which restores the SR register and branches to the PC where the interrupt occurred.