program ttime; {test new XIOS timing function, and GET_TOD}

  const
    period = 90; {period in clock ticks - 1.5 seconds}
    stack_size = $1000; {main program stack size}

  type
    tod_type =
      record
	day: integer;
	hour: byte;
	min: byte;
	sec: byte
      end;

  var
    t_entry: longint;
    i: integer;
    tod: tod_type;

  external procedure delay(ticks: integer);
  external function x_time: longint;
  external procedure get_tod(var tod: tod_type);
  external procedure init_mpm_util(size: integer);

  begin
    init_mpm_util(stack_size);

    repeat {do forever, ^C to stop}
      t_entry := x_time;
      writeln('x_time = ', t_entry);

      get_tod(tod);
      with tod do
	begin
	write('day = ', day, '   time = ');
	if hour < 10 then
	  write('0');
	write(hour, ':');
	if min < 10 then
	  write('0');
	write(min, ':');
	if sec < 10 then
	  write('0');
	writeln(sec);
	end;
      {other processing could go here}

      delay(period - short(x_time - t_entry));

    until false;

  end.
