[Coco] os9 intercept call from C

Walter Zambotti zambotti at iinet.net.au
Sat Apr 18 00:27:09 EDT 2020


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




More information about the Coco mailing list