Previous: External Declaration To the Table of Content Next: Procedural Value

- 2.2.12.4 -
TMT Pascal Language Description
Pascal Language Structure
Procedures and Functions

Interrupt Procedure

Targets: MS-DOS only


In TMT Pascal, the Interrupt clause defines a procedure that is to be used as an interrupt handler.

The parameters of an interrupt procedure are the CPU registers. The following is the order of the CPU registers: EFLAGS, CS, EIP, EAX, EBX, ECX, EDX, ESI, EDI, DS, ES, EBP. If these register variables are assigned a new value, upon completion of the interrupt the new values will be restored onto the actual CPU registers.

Declaration:
  procedure IntProc(used registers); interrupt;
An example below shows you a simple method of working with interrupt-handlers.
program Timer1;
uses
  Dos, Crt;
var
  Int1CSave: FarPointer;
  Time: LongInt;

// TimerHandler
procedure TimerHandler; interrupt;
var
  StoreX, StoreY: Word;
begin
  Inc(time);
  StoreX:= WhereX;
  StoreY:= WhereY;
  GotoXY(1,1);
  Write(time);
  GotoXY(StoreX, StoreY);
  Port[$20] := $20;
end;

begin
  ClrScr;
  Time := 0;
  GetIntVec($1C, Int1CSave);
  SetIntVec($1C, @TimerHandler);
  Writeln;
  Writeln('Type something and press "ENTER"to exit');
  Readln;
  SetIntVec($1C, Int1CSave);
end.
When using Intr and MsDos, keep in mind that the DOS interrupt handlers can deal only with the addresses from the 1st megabyte of memory.


Previous: External Declaration To the Table of Content Next: Procedural Value
External Declaration Table of Content Procedural Value

- 2.2.12.4 -