program WAIT;
Uses Crt, Dos;
var oldtimer : pointer;
    mscount  : longint;
    msready  : boolean;
    i        : integer;
procedure WaitInt; Interrupt;
begin
  dec(mscount);
  if mscount = 0 then msready := true;
  port [$20] := $20;
end;

procedure Wait1(ms : longint);
begin
 GetIntVec(8,oldtimer);
 SetIntVec(8,@waitint);
 asm
   cli
   mov dx,43h
   mov al,36h
   out dx,al
   sub dx,3
   mov al,169
   out dx,al
   mov al,4
   out dx,al
   sti
 end;
 msready := false;
 mscount := ms;
 repeat until msready;
 asm
   cli
   mov dx,43h
   mov al,36h
   out dx,al
   sub dx,3
   xor ax,ax
   out dx,al
   out dx,al
   sti
 end;
 SetIntVec(8,oldtimer);
end;

begin
  clrscr;
  for i := 5 downto 1 do begin
    gotoxy(10,6);
    writeln('Please wait ',i,' seconds');
    wait1(1000);
  end;
end.