Article View: net.micro.atari16
Article #2427Re: Interrupt running programs
From: braner
Date: Sat, 18 Oct 1986 04:58
Date: Sat, 18 Oct 1986 04:58
95 lines
3371 bytes
3371 bytes
[]
Finally, it seems I am on the right track towards writing a program
that will stop other programs. The following, after running, sits
in RAM invisibly, until you hold down Control, Alternate and BOTH
shift keys and press another key (e.g. Return). The program in
progress at the time will be terminated.
One problem I had to solve was how to avoid OS calls from
inside the interrupt handler. I did that by using direct
peeking of the shift keys status, and by doing the actual
termination of the program AFTER the RTE.
WARNING: This program uses some addresses that are essential
but not official. I found them out by snooping around in the
ROM code. They may be changed in future versions of TOS.
Atari will send their death squads after you if you use these
addresses in a commercial program!
Here is the heart of the routine, in commented assembly syntax:
asm {
/*
* call supexec() to install our thing
*/
PEA install(PC)
MOVE.W #38,-(A7)
TRAP #14
ADDQ.L #6,A7
/*
* terminate and stay resident
*/
CLR.W -(A7)
MOVE.L #0x00000200,-(A7)
MOVE.W #0x31,-(A7)
TRAP #1
install:
/*
* install our keyboard interrupt handler
* (has to be done in supervisor mode)
*/
PEA handler(PC)
MOVE.L (A7)+,0x118 /* pointer to kbd intrpt subr */
RTS
handler:
/*
* check keyboard shift status
*/
CMPI.B #0x0F,0xE1B /* shift status variable */
BCS.S normal
/*
* overwrite return address with our posthandler
*/
PEA killer(PC)
MOVE.L (A7),6(A7)
ADDQ.L #4,A7
normal:
/*
* go do the usual thing, usually return to interrupted program
*/
JMP 0xFC281C /* where $118 pointed to */
killer:
/*
* RTE to here to terminate program
*/
CLR.L -(A7)
TRAP #1
/*
* should not come back, but: 6 bombs if you do
*/
CHK #-1,D0
}
Here is a hex dump of the complete program (140 bytes):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60 1A 00 00 00 70 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 FF FF 2A 4F 2A 6D
00 04 20 2D 00 0C D0 AD 00 14 D0 AD 00 1C D0 BC
00 00 01 00 2F 00 2F 0D 3F 00 3F 3C 00 4A 4E 41
DF FC 00 00 00 0C 48 7A 00 1A 4E 71 3F 3C 00 26
4E 4E 5C 8F 42 67 2F 3C 00 00 02 00 3F 3C 00 31
4E 41 48 7A 00 08 21 DF 01 18 4E 75 0C 38 00 0F
0E 1B 65 0A 48 7A 00 0E 2F 57 00 06 58 8F 4E F9
00 FC 28 1C 42 A7 4E 41 41 BC FF FF
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please try it out and comment on its performance under various
circumstances. Remember: the object is a clean break, with no
after effects, avoiding RESETs when possible.
- Moshe Braner
<braner@amvax.tn.cornell.edu>
P.S. I have not tried "Watcher" yet - it may be similar or better?
Technical Details
Message-ID:
<1230@batcomputer.TN.CORNELL.EDU>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!rutgers!sri-spam!sri-unix!hplabs!tektronix!uw-beaver!cornell!batcomputer!branerReferences:
<14600008@uklirb.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!rutgers!sri-spam!sri-unix!hplabs!tektronix!uw-beaver!cornell!batcomputer!braner From: braner@batcomputer.TN.CORNELL.EDU (braner) Newsgroups: net.micro.atari16 Subject: Re: Interrupt running programs Message-ID: <1230@batcomputer.TN.CORNELL.EDU> Date: Sat, 18-Oct-86 00:58:19 EDT Article-I.D.: batcompu.1230 Posted: Sat Oct 18 00:58:19 1986 Date-Received: Tue, 21-Oct-86 05:47:29 EDT References: <14600008@uklirb.UUCP> Reply-To: braner@batcomputer.UUCP (braner) Organization: Theory Center, Cornell University, Ithaca NY Lines: 95 Summary: a short program that seems to work