[Coco] os9 intercept call from C
Alex Evans
varmfskii at gmail.com
Sat Apr 18 11:38:08 EDT 2020
Largely ignoring the fact that the above code uses ANSI syntax and the
only MW C Compiler I am aware of for the CoCo uses K&R. If you use the
provided intercept function in the library, the function to be called
is a normal C function which takes an integer as a parameter (no RTI).
If you are going to finable about directly using F$Icpt to set you
trap, it needs to return using RTI. In addition, you need to set the
pointer to the routine's storage area in U, but in the case of the
function you have provided, it does not appear to need any storage
space, so the fact you didn't set U shouldn't be a problem.
I would think (untested) the answer would be:
int catchall();
int intflag=0;
main(argc, argv)
int argc;
char *argv[];
{
intercept(catchall);
while (!intrlag) {
pause();
write(1, "*", 1);
}
}
catchall(sig)
int sig;
{
intfrag=sig==0x03;
}
If your really, really want to directly use the system call, you need
to also pull the signal number from somewhere. The routine expexted by
F$cpt is a machine code routine, and sig will probably not be passed
on the stack in the manner that MW C expects, so you need to figure
out where it would be.
More information about the Coco
mailing list