[Coco] Hook an IRQ in CMOC?

Joel Rees joel.rees at gmail.com
Thu Nov 9 02:15:07 EST 2017


Pierre,

Looks like you've done some very nice work.

2017/11/09 9:31 "Pierre Sarrazin" <sarrazip at sarrazip.com>:

> Hi Randy,
>
> Dixit Randy Weaver (2017-11-08 06:51):
> > Are their any examples of hooking an IRQ to a CMOC function?
>
> Here is one. First, define the service routine using the "interrupt"
> keyword, and use certain ports to test that the IRQ is due to the 60
> Hz timer:
>
>     interrupt void irqISR()
>     {
>         if ((* (char *) 0xFF03) & 0x80)  // do nothing if 63.5 us interrupt
>         {
>             // 60 Hz interrupt. Reset PIA0, port B interrupt flag.
>             * (char *) 0xFF02;
>
>             // Do something that needs to be done every 60th of a second.
>         }
>     }
>
> Then, install that function as the IRQ handler:
>
>     #include <coco.h>
>
>     [...]
>
>     disableInterrupts();
>     byte *isr = * (byte **) 0xFFF8;
>     *isr = 0x7E;  // JMP extended
>     * (void **) (isr + 1) = irqISR;
>     enableInterrupts();
>
> Inline assembly can be used if more efficiency is needed.
>
> This and other topics are covered in the manual:
> http://sarrazip.com/dev/cmoc-manual.html
> http://sarrazip.com/dev/cmoc.html
>
> --
> Pierre Sarrazin <sarrazip @ sarrazip . com>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>


More information about the Coco mailing list