[Coco] os9 intercept call from C

Bill Pierce ooogalapasooo at aol.com
Sat Apr 18 05:00:40 EDT 2020


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


More information about the Coco mailing list