Previous: 2.2.12.3. External Declaration To the Table of Contents Next: 2.2.12.5. Procedural Value
2.2.12.3. External Declaration Table of Contents 2.2.12.5. Procedural Value

- 2.2.12.4. -
Table of Contents
2. TMT Pascal Language Description
2.2. Pascal Language Structure
2.2.12. Procedures and Functions
2.2.12.4. Interrupt Procedure


2.2.12.4. 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: 2.2.12.3. External Declaration To the Table of Contents Next: 2.2.12.5. Procedural Value
2.2.12.3. External Declaration Table of Contents 2.2.12.5. Procedural Value

- 2.2.12.4. -