Article View: net.micro.atari16
Article #1616Catching The Kill Character Using Megamax C
From: Gert Poletiek
Date: Tue, 26 Aug 1986 10:26
Date: Tue, 26 Aug 1986 10:26
63 lines
1705 bytes
1705 bytes
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.
Technical Details
Message-ID:
<201@nikhefh.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!mcvax!nikhefh!gertShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!mcvax!nikhefh!gert From: gert@nikhefh.uucp (Gert Poletiek) Newsgroups: net.micro.atari16 Subject: Catching The Kill Character Using Megamax C Message-ID: <201@nikhefh.UUCP> Date: Tue, 26-Aug-86 06:26:30 EDT Article-I.D.: nikhefh.201 Posted: Tue Aug 26 06:26:30 1986 Date-Received: Wed, 27-Aug-86 10:14:57 EDT Organization: NIKHEF-H Amsterdam (the Netherlands) Lines: 62 Apparently-To: rnews@mcvax