[Coco] os9 intercept call from C

James Jones jejones3141 at gmail.com
Sat Apr 18 10:37:22 EDT 2020


Does the function you register with intercept() actually have to rti, or
does it just return to something that does the rti? (Looking at the manual,
I believe the latter is the case.)

On Sat, Apr 18, 2020 at 4:00 AM Bill Pierce via Coco <coco at maltedmedia.com>
wrote:

> If you are using the standard C lib (clib.l), intercept is already defined
> in the library. You just call it. remove your "intercept(int (func)(int))"
> routine and it will work.
>
>
> -----Original Message-----
> From: Walter Zambotti <zambotti at iinet.net.au>
> To: CoCoList for Color Computer Enthusiasts <coco at maltedmedia.com>
> Sent: Sat, Apr 18, 2020 12:27 am
> Subject: [Coco] os9 intercept call from C
>
> Trying to use the intercept call that is documented in the MW C manual
> page 25.
>
> The function isn't actually provided in clib.
>
> So i tried to write it but I'm crashing OS9 when I use it.
>
> int intrflag = 0;
>
> CatchAll(int sig)
> {
>   intrflag = sig == 0x03;
> #asm
>   rti
> #endasm
> }
>
> intercept(int (*func)(int))
> {
>   struct registers reg;
>   reg.rg_x = (int)func;
>   _os9(F_ICPT, &reg);
>   return reg.rg_b;
> }
>
> main(int argc, char **argv)
> {
>   intercept(CatchAll);
>   while(!intrflag)
>   {
>     pause();
>     write(1, "*", 1);
>   }
> }
>
> As you can see I also tried using an rti from the trap function (CatchAll).
>
> Walter
>
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>


More information about the Coco mailing list