Article View: comp.lang.modula2
Article #3427Interrupt Handlers in Topspeed Modula 2 V1.17
From: Martin Harvey
Date: Wed, 27 Mar 1996 16:03
Date: Wed, 27 Mar 1996 16:03
94 lines
3047 bytes
3047 bytes
-- Hi,
I'm trying to write an interrupt handler that intercepts the keyboard
interrupt. I've looked in the documentation that I have, and two
alternative approaches seem to appear:
1. Write the handler as a procedure.
eg.
MODULE Int
VAR KbdInt [??:??] :ADDRESS;
(*seg ofs address for keyboard interrupt vector *)
OldInt:ADDRESS;
(*$J+,C FF*) (*Save all regs, and have IRET *)
PROCEDURE Handler;
BEGIN
.....
END Handler;
(*$J-,C F0*) (*Normal procedure return conventions *)
BEGIN
OldInt:=KbdInt;
KbdInt:=ADR(Handler);
..... (*Bit of code where we want handler to work *)
KbdInt:=OldInt;
END Int.
However, there seems to be a possible way of doing it, by using the
system procedures TRANSFER and IOTRANSFER Perhaps something like this??
(excuse the likely errors here!)
MODULE Int;
VAR
Main,Handler:SYSTEM.Process;
HandlerSpace:ARRAY[0..4096] OF BYTE;
CONST
IntNo=16H;
PROCEDURE Handler;
VAR
ExRegs:SYSTEM.ExtendedRegisters;
BEGIN;
LOOP
IOTRANSFER(Handler,Main,IntNo);
ExRegs:=(SYSTEM.InterruptRegisters(Handler))^;
(* Handling Gunk down here *)
END;
END Handler;
BEGIN;
SYSTEM.NEWPROCESS(Handler,ADR(HandlerSpace),SIZE(HandlerSpace),Handler);
SYSTEM.TRANSFER(Main,Handler);
(*Code where we want all this to take effect *)
END Int.
There are several things that I can't seem to find explained very well:
If I want to write a keyboard interrupt handler, I will want to make it
so that when my procedure returns, the registers are modified as if a
call to the original handler had occured (at least most of the time,
until the right keystroke(s) are entered) how do I do this??
The First example modifies the interrupt vector table directly. If i
want to use this method, how do I calculate the address for any given
interrupt??
And lastly: which of the above is the most practical/workable?? I would
greatly appreciate a quick pointer in the right direction from someone
who has tried this before :-)
Sincerely
-------------------------------------------------------------
| Martin Harvey |
| Term Time: mch24@cam.ac.uk |
| Holidays: mch24@harvey27.demon.co.uk |
| |
| Home page: http://www.pem.cam.ac.uk:81/mch24/home.html |
-------------------------------------------------------------
Technical Details
Message-ID:
<496207970wnr@harvey27.demon.co.uk>Path:
arc1-ca.pugleaf.net!mail2news.demon.co.uk!harvey27.demon.co.ukShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!harvey27.demon.co.uk From: Martin Harvey <mch24@harvey27.demon.co.uk> Newsgroups: comp.lang.modula2 Subject: Interrupt Handlers in Topspeed Modula 2 V1.17 Date: Wed, 27 Mar 1996 16:03:20 GMT Organization: None Message-ID: <496207970wnr@harvey27.demon.co.uk> Reply-To: mch24@harvey27.demon.co.uk X-NNTP-Posting-Host: harvey27.demon.co.uk X-Broken-Date: Wednesday, Mar 27, 1996 16.03.20 X-Newsreader: Newswin Alpha 0.7 X-Mail2News-Path: relay-4.mail.demon.net!post.demon.co.uk!harvey27.demon.co.uk