I understand that the interrupt vectors like vblank are fixed in ROM. The standard way of getting round this (as I understand) is storing a redirection vector table in RAM. Then the main interrupt routine looks up the dynamic vector in the RAM and adjusts the instruction pointer.
crt0.s
Code: Select all
.data
.global vblank_vector
vblank_vector:
.long 0
Code: Select all
extern unsigned int vblank_vector;
Code: Select all
vblank:
move.l vblank_vector,-(sp)
beq.b 1f
rts
1:
addq.l #1,gTicks
addq.l #4,sp
rte
Code: Select all
void vblankcallback()
{
put_str("Invoked from vector", 0x2000, 20-7, 2);
}
int main(void)
{
vblank_vector = &vblankcallback;
...
}
I have been trying may variations for several hours including placing instructions like __asm("rte") at the end of vblankcallback to try to end the interrupt but everything seems ineffective.
I their a proper way to redirect interrupts to C void return functions?