Code: Select all
'//This routine is called every 1.24 usec (49 cycles @79MHz). It provides 7 timeslots.
'//These run at priority 7 to ensure deterministic behaviour for all states.
'//Cycles is 16 + statefunction cycles
'//Only registers w0-w5 must be used by vp driver code because other w registers are not saved.
'//The interrupt frequency for each timeslot equals 1/(7*1.24) MHz = 115.2 kHz
sub procedure T4Interrupt org 0x003E '//On C30 this autogenerates push.s and pop.s statements)
dim slot as ^vpBank rx '// asm("w5");
slot = vpPtr '//this value is used in all statefunctions
slot^.statePtr^ '//call statefunction for slot
vpPtr = slot^.nextVP '//next vp
IFS1.T4IF = 0 '//clear T4 interruptflag
asm
push.s ; //save w0-w3,status
mov.d w4,[w15++] ; //save w4,w5
mov _vpPtr,w5 ; //slot = vpPtr; //this value is used in all statefunctions
mov.w [w5+16],w0 ; //(slot->statePtr)(); //call statefunction for slot
;call w0 ;
mov.w [w5+18],w0 ; //vpPtr = (vpBank *)slot->nextVP; //next vp
mov w0,_vpPtr ;
bclr.b IFS1,#3 ; //IFS1bits.T4IF = 0; //clear T4 interruptflag
mov.d [--w15],w4 ; //restore w4,w5
pop.s ; //restore w0-w3,status
end asm
end sub
Code: Select all
_T4Interrupt:
;RGBWSv0_01p.mbas,99 :: dim slot as ^vpBank rx '// asm("w5");
;RGBWSv0_01p.mbas,102 :: vpPtr = slot^.nextVP '//next vp
0x0238 0x804000 MOV _vpPtr, W0
0x023A 0xECA000 INC2 W0, 1
0x023C 0x780010 MOV [W0], W0
0x023E 0x884000 MOV W0, _vpPtr
;RGBWSv0_01p.mbas,103 :: IFS1.T4IF = 0 '//clear T4 interruptflag
0x0240 0xA96087 BCLR IFS1, #11
;RGBWSv0_01p.mbas,105 :: push.s ; //save w0-w3,status
0x0242 0xFEA000 PUSH.S
;RGBWSv0_01p.mbas,106 :: mov.d w4,[w15++] ; //save w4,w5
0x0244 0xBE9F84 MOV.D W4, [W15++]
;RGBWSv0_01p.mbas,107 :: mov _vpPtr,w5 ; //slot = vpPtr; //this value is used in all statefunctions
0x0246 0x804005 MOV _vpPtr, W5
;RGBWSv0_01p.mbas,108 :: mov.w [w5+16],w0 ; //(slot->statePtr)(); //call statefunction for slot
0x0248 0x900805 MOV [W5++16], W0
;RGBWSv0_01p.mbas,110 :: mov.w [w5+18],w0 ; //vpPtr = (vpBank *)slot->nextVP; //next vp
0x024A 0x900815 MOV [W5++18], W0
;RGBWSv0_01p.mbas,111 :: mov w0,_vpPtr ;
0x024C 0x884000 MOV W0, _vpPtr
;RGBWSv0_01p.mbas,112 :: bclr.b IFS1,#3 ; //IFS1bits.T4IF = 0; //clear T4 interruptflag
0x024E 0xA96086 BCLR.B IFS1, #3
;RGBWSv0_01p.mbas,113 :: mov.d [--w15],w4 ; //restore w4,w5
0x0250 0xBE024F MOV.D [--W15], W4
;RGBWSv0_01p.mbas,114 :: pop.s ; //restore w0-w3,status
0x0252 0xFE8000 POP.S
;RGBWSv0_01p.mbas,115 :: end asm
L_end_T4Interrupt:
0x0254 0x064000 RETFIE
; end of _T4Interrupt
99 1011 Hint: Variable "slot" has been eliminated by optimizer RGBWSv0_01p.mbas
Due to the elemination, the call to stateFunction via pointer
is omitted. The asm statement shows the code as it should
be compiled.
Also like to know how I can reserve a specific workregister
in this case w5. Perhaps allow modifiers rx0 to rx15 as well as rx.
regards peter