home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS - Coast to Coast
/
simteldosarchivecoasttocoast.iso
/
pcmag
/
vol6n20.zip
/
FIGURES.ZIP
/
FIGURE.1
next >
Wrap
Text File
|
1987-10-16
|
1KB
|
45 lines
(*********************************************************)
(* Include this file in your programs as TIMER.INC. *)
(* A typical use of the routine would look like this: *)
(* timer(on); *)
(* FOR I := 1 to 10000 DO {something}; *)
(* timer(off); *)
(* Write('10,000 repetitions of {something} took '); *)
(* WriteLn(time:1:2,' seconds.'); *)
(*********************************************************)
TYPE OnOrOff = (On, Off);
VAR start, time : Real;
PROCEDURE timer(O : OnOrOff);
TYPE
Registers = RECORD
CASE Integer OF
1 : (AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags : Integer);
2 : (AL, AH, BL, BH, CL, CH, DL, DH : Byte);
END;
VAR
R : Registers;
hour, min, sec, hun : Integer;
BEGIN
R.AH := $2C;
Intr($21, R); {call interrupt}
WITH R DO
BEGIN
hour := CH;
min := CL;
sec := DH;
hun := DL;
END;
IF O = On THEN
BEGIN
start := hour*3600 + min*60 + sec + hun/100;
time := 0;
END
ELSE
BEGIN
time := hour*3600 + min*60 + sec + hun/100 - start;
start := 0;
END;
END;