I'm currently working on a time critical design using normal interrupt and fast interrupt, I need to write my own interrupt handler because I used assembly code and C code in interrupt, and currently pragma interrupt only handle the CPU register that C code used on my project.
I know CW provide 3 kind of interrupt handle pragma.
- interrupt on : only handle C code, can only generate rti at last
- interrupt saveall on: save too much register, can only generate rti at last
- interrupt fast on : only handle C code, can only generate frtid at last
I can use neither these 3 kind interrupt handler.
I tried to write my own interrupt handler, but CW always determine my handler as a subroutine, it will modify stack and CPU register that I don't need at the top and the end.
my code:
inline void FastISRRegSave (void)
{
asm(
adda #<2,sp
move.l a2,x:(sp)+
move.l a10,x:(sp)+
move.l b2,x:(sp)+
move.l b10,x:(sp)+
move.l c2,x:(sp)+
move.l c10,x:(sp)+
move.l d2,x:(sp)+
move.l d10,x:(sp)+
move.l x0,x:(sp)+
bfset #$ffff,m01
);
}
inline void FastISRRegRestore (void)
{
asm(
move.l x:(sp)-,x0
move.l x:(sp)-,d
move.l x:(sp)-,d2
move.l x:(sp)-,c
move.l x:(sp)-,c2
move.l x:(sp)-,b
move.l x:(sp)-,b2
move.l x:(sp)-,a
move.l x:(sp)-,a2
frtid
nop
nop
);
}
compiler code:
0x00000000 FivINT_eFlexPWMA_CMP2:
0x00000000 0x827B adda #0x000002,SP
0x00000001 0xD22B move.l C10,X:(SP)+
0x00000002 0xDD3F move.l R5,X:(SP)
; 290: FastISRRegSave();
; 291:
0x00000003 0x827B adda #0x000002,SP
0x00000004 0xE500 move.l A2,X:(SP)+
0x00000005 0xD02B move.l A10,X:(SP)+
0x00000006 0xE501 move.l B2,X:(SP)+
0x00000007 0xD12B move.l B10,X:(SP)+
0x00000008 0xE502 move.l C2,X:(SP)+
0x00000009 0xD22B move.l C10,X:(SP)+
0x0000000A 0xE503 move.l D2,X:(SP)+
0x0000000B 0xD32B move.l D10,X:(SP)+
0x0000000C 0xE504 move.l X0,X:(SP)+
0x0000000D 0x835AFFFF bfset #0xffff,M01
FastISRRegRestore();
0x0000013B 0xE514 move.l X:(SP)-,X0
0x0000013C 0xF33B move.l X:(SP)-,D
0x0000013D 0xE513 move.l X:(SP)-,D2
0x0000013E 0xF23B move.l X:(SP)-,C
0x0000013F 0xE512 move.l X:(SP)-,C2
0x00000140 0xF13B move.l X:(SP)-,B
0x00000141 0xE511 move.l X:(SP)-,B2
0x00000142 0xF03B move.l X:(SP)-,A
0x00000143 0xE510 move.l X:(SP)-,A2
0x00000144 0xE71A frtid
0x00000145 0xE700 nop
0x00000146 0xE700 nop
0x00000147 0xFD3B move.l X:(SP)-,R5
0x00000148 0xF23B move.l X:(SP)-,C
0x00000149 0xE708 rts
Is there any way to make DSC compiler do not generate these code?