Delay and Pentium 
Author Message
 Delay and Pentium

  I upgraded my computer to a Pentium and the Delay commands in my
Turbo Pascal 5.5 programs no longer work.  I gather that whatever trick
TP 5.5 uses to achieve clock-independent delay times is foiled by the
Pentium architecture.

  Anyone know how to make a program pause for a fixed length of time with TP
5.5 in a Pentium computer?



Wed, 18 Jun 1902 08:00:00 GMT  
 Delay and Pentium
        My guess is simply to increase the delay time accordingly. After
all, I have never heard of it failing to work...
                                                                Todd

************************************************************************
* Visit my homepage at   http://www.afn.org/~afn32685
* Communication is the difference between a friend and an acquaintance
************************************************************************



Wed, 18 Jun 1902 08:00:00 GMT  
 Delay and Pentium

Quote:

>   I upgraded my computer to a Pentium and the Delay commands in my
> Turbo Pascal 5.5 programs no longer work.  I gather that whatever trick
> TP 5.5 uses to achieve clock-independent delay times is foiled by the
> Pentium architecture.

It's not the Pentium architecture that's the problem, it's the speed of the
processor - any fast 486's will have the same problem. When the CRT unit
initializes it does a test to measure the speed of the CPU to setup the
Delay procedure. It does this by incrementing a counter for a fixed length of
time. With the advances in processor speed this counter can overflow, this
gives a totally incorrect value and prevents the Delay procedure being usable.

Quote:
>   Anyone know how to make a program pause for a fixed length of time with TP
> 5.5 in a Pentium computer?

Use a later version of Turbo Pascal, TP7 is OK, and the later versions of TP6,
for the early TP6 there is a patch available to correct the problem. I don't
know if there is a patch for TP5.5, but you could check with Borland.

BTW, the older versions of Turbo C have the same problem.

Nigel.

          /----------------------------------------------------------\

          | Lower Pilsley   |                                        |
          | Chesterfield    |                                        |
          | England         |                                        |
          \----------------------------------------------------------/



Wed, 18 Jun 1902 08:00:00 GMT  
 Delay and Pentium

Quote:

>  I upgraded my computer to a Pentium and the Delay commands in my
>Turbo Pascal 5.5 programs no longer work.  I gather that whatever trick
>TP 5.5 uses to achieve clock-independent delay times is foiled by the
>Pentium architecture.

>  Anyone know how to make a program pause for a fixed length of time with TP
>5.5 in a Pentium computer?

No; the trick is foiled by the PC's speed, and delay is wrong on (AFAIR)
a 486/33.  AIUI, the problem is that it calibrates itself by counting
for 1/18.2 sec, using a word counter, which overflows and causes
miscalibration.

Seek Kris Heidenstrom's Timing FAQ ; Kris's address incluses Actrix & NZ
- from memory - apologies for any spelling - I wonder whether Timo's or
Tom's or other FAQ has the reference.  

But AFAIR, see Timo's FAQ -- #10 may help; #67 should --- Are you there,
Timo? #67 needs an update :


expanded below. It has the advantage of being concise and working in
the protected mode. The disadvantage is that it requires a later TP
version. The solution is quite instructive.
  uses Dos;
  {... John's procedure ...}
  procedure WAIT (SecondsDelay : real) ;
  Var Tptr : ^longint ; Finish : longint ;
  begin
    Tptr := Ptr(Seg0040, $006C) ;
    Finish := Tptr^ + Round(18.2*SecondsDelay) ;
    repeat until Tptr^ > Finish ;
  end;
  {... now let's test it ...}
  var h1, m1, s1, sa100 : word;
      h2, m2, s2, sb100 : word;
  begin
    GetTime (h1, m1, s1, sa100);
    WAIT (3);
    GetTime (h2, m2, s2, sb100);
    writeln (h1, ':', m1, ':', s1, '.' ,sa100);
    writeln (h2, ':', m2, ':', s2, '.' ,sb100);
  end.

I have since realised that Tptr^ is evaluated non-atomically by TP/BP;
the 4-byte longint is accessed 2 bytes at a time, and could be updated
in between, and once an hour there is a carry (and worse if midnight is
noticed).  I'd now suggest something like (the following is UNTESTED and
from memory, but something like it is certainly OK), which counts
changes in the clock.  Or one can disable & re-enable interrupts around
TPtr^.

  procedure WAIT (SecondsDelay : extended) ;
  var Tptr : ^byte ; XT, YT : byte ; Finish : longint ;
  begin Finish := Round(18.2*SecondsDelay) ;
    Tptr := Ptr(Seg0040, $006C) ; XT := TPtr^ ;
    repeat YT := TPtr^ ;
      if XT<>YT then begin XT := YT ; Dec(Finish) end ;
      until Finish<=0 ;
  end;

(* This uses Seg0040; before V7.00, just use $0040.  One can also
   {often} omit Tptr & use var T : byte absolute $40:$6C instead of  
   Tptr^; the technique should work for any version or language on a PC.  
   It would be antisocial in Windows or on a multi-user system *)
--
John Stockton, Surrey, UK.  Turnpike v1.12.  MIME.



Wed, 18 Jun 1902 08:00:00 GMT  
 Delay and Pentium
Quote:

>   I upgraded my computer to a Pentium and the Delay commands in my
> Turbo Pascal 5.5 programs no longer work.  I gather that whatever trick
> TP 5.5 uses to achieve clock-independent delay times is foiled by the
> Pentium architecture.

>   Anyone know how to make a program pause for a fixed length of time with TP
> 5.5 in a Pentium computer?

Just read out the system time and write your own delay !

--
-=!------------------------------------------------------------------------!=-
 Have a look at our WWW-Page http://www.informatik.uni-oldenburg.de/~virtech/
 Get the latest games, programs and demos from vIRtECH!  Get cool SOURCE CODE
 (Pascal/x86asm).  Have a look at our CPC Page or just make a journey through
 the BUNKR.   ATTENTION: The SOURCE of our PC Spiel Pinball is now available!



Wed, 18 Jun 1902 08:00:00 GMT  
 Delay and Pentium

Quote:

>  I upgraded my computer to a Pentium and the Delay commands in my
>Turbo Pascal 5.5 programs no longer work.  I gather that whatever trick
>TP 5.5 uses to achieve clock-independent delay times is foiled by the
>Pentium architecture.
>  Anyone know how to make a program pause for a fixed length of time with TP
>5.5 in a Pentium computer?

The problem is that 5.5's Crt unit uses a 16bit value for the delay counter
which is not enough on a Pentium. I had the same problem even on a 486-50.
(So it's nothing special about the Pentium architecture, the processor is
just too fast.)

Possible solutions:
- Fix the Crt unit (I did that - requires some knowledge of assembler programming)
- Get a newer BP version (I _think_ 6.0 has the problem, too, but 7.0
  definitely hasn't)
- If the required delay is a multiple of 1/18.2 seconds, you can use the
  system timer at $40:$6C, e.g.

  var t:longint;
      systimer:longint absolute $40:$6C;
  begin
    t:=systimer;
    repeat until systimer=t+18; {Approx. 1 sec. delay}
  end.

Hope this helps,
Frank



Wed, 18 Jun 1902 08:00:00 GMT  
 Delay and Pentium

Quote:

>Subject: Re: Delay and Pentium
>Date: 1 Apr 1996 10:53:34 GMT

>>  I upgraded my computer to a Pentium and the Delay commands in my
>>Turbo Pascal 5.5 programs no longer work.  I gather that whatever trick
>>TP 5.5 uses to achieve clock-independent delay times is foiled by the
>>Pentium architecture.
>>  Anyone know how to make a program pause for a fixed length of time with TP
>>5.5 in a Pentium computer?
>The problem is that 5.5's Crt unit uses a 16bit value for the delay counter
>which is not enough on a Pentium. I had the same problem even on a 486-50.
>(So it's nothing special about the Pentium architecture, the processor is
>just too fast.)

The problem occurs on everything from a 33 MHz 386. The error was fixed in a
maintenance release (Ver. 6.01) of TP 6, but Borland kept very quiet about it.
BP 7/TP 7 does not have this error.

There have been some patches floating around. Check by ftp at
  garbo.uwasa.fi
which has a most extensive source of Pascal files.

/Lars Renman



Wed, 18 Jun 1902 08:00:00 GMT  
 Delay and Pentium
  Many thanks to all who responded.


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Delay on Pentium

2. Pentium processors and Delay()

3. Pentium vs Pentium Pro code

4. strange tp7 error on Pentium Computers

5. BPC.exe behaves differently on pentium III machines..

6. How to read or modify pentium register CR0 ?

7. How to read or modify pentium register CR0 ?

8. borland pascal programs don't run with intel pentium II

9. +++GET YOUR FREE PENTIUM CELERON-300+++____________________________________________________________________________________________rtyu4598rut oiwty etijew u65her iuer

10. BP7 + Pentium III

11. Borland Pascal 7 CRT unit on Pentium II

12. Pentium II Problem with BP7.0?

 

 
Powered by phpBB® Forum Software