gert@nikhefh.uucp (Gert Poletiek) (08/26/86)
It took me some time before i realized why the code i used with other C compilers to catch the ^C Kill character wouldn't work with Megamax. At last i found that the code the Megamax compiler generates is position indepentent, and the data is referred to using an offset from register A4. So when a control C is typed the first thing you have to do is restore the value of a4 to gain access to the global variables. The value of a4 must be saved so that it can be retrieved not using a a4 offset. This leaves only ta location in the code segment, which can be accessed using a PC relative addressing mode. This is the code i use now: /* * Next routine is really a dirty trick to get some storage * that is not accessed using a4 offset. */ extern _store_a4(); asm{ _store_a4: dc.l 0 } KillHandler () { asm{ movea.l _store_a4(PC),A4 } longjmp ( whereveryouwanttogo, 1 ); } SetNoKill () { asm{ lea _store_a4(PC),A0 move.l A4,(A0) } OldKill = Setexc ( 0x102, KillHandler ); } ResetKill () { Setexc ( 0x102, OldKill ); } Gert Poletiek Dutch National Institute for High Energy Physics Amsterdam The Netherlands.