home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
PARADIS1
/
INTERUPT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-01-28
|
3KB
|
114 lines
(10221) Sat 25 Jan 92 20:41
By: Mike Hindle
To: All
Re: Interrupt Handlers
St:
---------------------------------------------------------------------------
@MSGID: 1:153/722 8676b2f1
@PID: TeleMail 1.49f
Question of the day: How to correctly write an interrupt handler?
The following code seems to work ok, but continually does weird things
to my system. It runs for awhile then at random points in time, my system
locks up, reboots, displays garbage on the screen, makes the hard drive go
nuts, and confuses my modem. I'd say the timer doesn't appreciate being
interrupted.
Would whoever responds to this message please provide a general background
on interrupt handlers ie: why disable/enable interrupts, whether the saved
interrupt address should be called, whether it is necessary to push the
flags before calling the saved interrupt address, etc. etc.
Now of course, I am seeking a cause and/or solution to the problem I am
having with the following TP 5.0 code.
VAR
TimerCnt : byte;
OldInt1C : procedure;
I : byte;
HStr,
MStr,
SStr,
Temps : string;
IntTimeRcd : TimeRec;
ExitSave : pointer;
PROCEDURE StartDateTime;
{ This procedure sets up the interrupt driven date/time display. }
BEGIN
ExitSave := ExitProc;
ExitProc := @StopDateTime;
TimerCnt := 0;
GetIntVec($1C,@OldInt1C);
SetIntVec($1C,@UpdateTime);
END; { StartDateTime }
PROCEDURE StopDateTime;
BEGIN
Inline($FA); { CLI - Disable interrupts }
ExitProc := ExitSaveDateTime;
SetIntVec($1C,@OldInt1C); { Restore timer interrupt }
Inline($FB); { STI - Enable interrupts }
END; { StopDateTime }
PROCEDURE UpdateTime; Interrupt;
BEGIN
Inline($FA); { CLI - Disable interrupts }
Inc(TimerCnt);
IF TimerCnt = 18 THEN WITH IntTimeRcd DO
BEGIN
GetTime(Hour,Minute,Second,Sec100);
IF Hour < 12 THEN Temps := ' AM' ELSE Temps := ' PM';
IF Hour > 12 THEN Dec(Hour,12) ELSE IF Hour = 0 THEN Hour := 12;
Str(Hour:2,HStr);
Str(Minute,MStr);
Str(Second,SStr);
IF Minute < 10 THEN MStr := '0' + MStr;
IF Second < 10 THEN SStr := '0' + SStr;
Temps := HStr + ':' + MStr + ':' + SStr + Temps;
FOR I := 1 TO Length(Temps) DO
Monitor^[(2 * I) + 136] := Ord(Temps[I]);
TimerCnt := 0;
END; { if }
Inline($FB); { STI - Enable interrupts }
Inline($9C); { Push flags }
OldInt1C;
END; { UpdateTime }
{***************************************************************************}
BEGIN
StartDateTime;
.
.
.
StopDateTime;
END.
... Mike
--- Blue Wave/TGp v2.02a Beta
* Origin: The Welcome Mat - Van, BC - [604-439-6717] (1:153/722.0)
@PATH: 153/722 740 752 396/1 170/400 512/0 1007