[Coco] os9 intercept call from C

Walter Zambotti zambotti at iinet.net.au
Sat Apr 18 12:44:08 EDT 2020


Opps nine characters long!!!

Which is exactly when the Ansi front end will start converting long
variable names to hashes.

On 2020-04-19 00:41, Walter Zambotti wrote:
> That's what I have trying to say guys.
>
> The intercept function is not in the standard library as expected.
>
> At least for me if I comment out my intercept function then it fails to
> link with unresolved reference to intercept.
>
> Figured out what is going wrong with the missing intercept library function.
>
> An rdump shows it is in the library.
>
> The problem starts when compiling with Ansi front end.  It converts the
> reference to _hexvalue which I can see on the _ntbl file.
>
> Which it should not do.  Especially since 'intercept' is only 8
> characters long.
>
> I suppose that's another bug in the Ansi front end.
>
> I reverted the code back to K&R and it compiles and links with no problem.
>
> Thanks guys
>
> Walter
>
> On 2020-04-18 23:38, Alex Evans wrote:
>> 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