uses crt,tptimer;
Const
Inter : Word = 100;

var
q : word;
p1,p2 : pointer;
i,i1  : word;
l1,l2 : Longint;
RNDMatrix : Pointer;

{$i tflip}

begin
getmem (p1,64000);
getmem (p2,64000);

Getmem (RndMatrix,4100);
SetupRNDMatrix (seg(RndMatrix^),5);
                              { ^ -> max value}

asm
mov ax,13h
int 10h
end;

for i:=0 to 64000-1 do Mem[Seg(p1^):i]:=0;
for i:=0 to 64000-1 do Mem[Seg(p2^):i]:=0;

for i:=50 to 250 do
for i1:=50 to 150 do mem[seg(p1^):i+i1*320]:=byte(i1+i);
for i:=0 to 63999 do Mem[Seg(p2^):i]:=byte((i-q) mod 320);

l1:=readtimer;
for i:=1 to Inter do tflip16 (seg(p1^),seg(p2^));
          {Edo bale Tflip32, Tflip16, Tflip8
           i 32 bit ekdosi den doyleyei sosta, akomi}
l2:=readtimer;

for i:=0 to 64000-1 do mem[SEGA000:i]:=mem[seg(p1^):i];

readkey;

asm
mov ax,3
int 10h
end;

writeln ((l2-l1)/Inter :0:2,' microseconds');
writeln (1000000/((l2-l1)/Inter):0:2,' tflips per second');
readkey;
end.


