Crt Unit in Turbo Pascal 7.0 generates overflow 
Author Message
 Crt Unit in Turbo Pascal 7.0 generates overflow

Can anyone help me fix the problem with using Crt unit ? It generates
overflow error. I am using Pention II Compaq Deskpro.




Wed, 18 Jun 1902 08:00:00 GMT  
 Crt Unit in Turbo Pascal 7.0 generates overflow

Quote:

>Can anyone help me fix the problem with using Crt unit ? It generates
>overflow error. I am using Pention II Compaq Deskpro.

Not again. Well here is a patch:

Use RT200FIX as the first unit of the program. Use RT200DEL after
CRT.PAS in every module (main program/unit) that uses Delay(). There
is no need to use RT200SUB directly.

The fix is for TP 7.0 and real mode only. In pre-7.0 or PM there is
no fix, nor interference.

The execution first gets to the Initialization code of RT200Sub. It
hooks the int 0 handler. Then the execution goes to the CRT
initialization code. If it RTE200's then the int 0 handler in RT200Sub
is activated and DX:AX is divided by two and Dfix multiplied by 2. The
execution then returns to the division instruction. It can fail again
causing further division (and multiplication) by two until it does not
fail. After the CRT initialization the initialization code of RT200Fix
itself is executed. It just unhooks the int 0 handler of RT200Sub so that
further divisions by zero will directly trigger the TP int 0 handler
(That is established in the system unit initialization which always is
executed at the very beginning)

As the Dfix is multiplied by two every time the DX:AX is divided by
two in the loop handler then the proper delays can be restored by
multiplying the ms count given to delay by Dfix. However, to avoid
overflows a loop is better choice. RT200Del does just that in its
Delay. The overhead caused by the loop is insignificant.

-----------------------RT200FIX.PAS------------------------------

Unit RT200fix;

interface

uses RT200Sub,crt,dos;

implementation

{$ifdef ver70}
{$ifdef msdos}
Begin
  SetIntVec(0,Int0Save);   { Restore the Int 0 handler }
{$endif}
{$endif}
End.

-----------------------RT200DEL.PAS------------------------------

Unit RT200Del;

interface

uses RT200Fix,CRT,RT200Sub;

Procedure Delay(ms:word);

implementation

Procedure Delay(ms:word);
var i:word;
Begin
  for i:=1 to Dfix do CRT.Delay(ms);
End;

end.

-----------------------RT200SUB.PAS------------------------------

Unit RT200Sub;

interface

const dfix:word=1;       { call delay() dfix times }

Var int0Save:pointer;

implementation

{$ifdef msdos}
{$ifdef ver70}

uses dos;

Procedure Int0; assembler;
          asm
          shr dx,1        { divide dx:ax by 2 }
          rcr ax,1
          shl Dfix,1      { multiply Dfix by 2 }
          iret            { return to the DIV (286+) }
          end;

begin
  GetIntVec(0,Int0Save);

{$endif}
{$endif}
end.

----------------------------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 Crt Unit in Turbo Pascal 7.0 generates overflow


Quote:

> Can anyone help me fix the problem with using Crt unit ? It generates
> overflow error. I am using Pention II Compaq Deskpro.

Why haven't you read any other postings in this group, the last few days
there have been a hell of a lot about this subject. Try Pedt Scragg's
replacement CRT, http://www.pedt.demon.co.uk/crt/

Robert
--
Robert AH Prins

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 Crt Unit in Turbo Pascal 7.0 generates overflow

Quote:

> Can anyone help me fix the problem with using Crt unit ? It generates
> overflow error. I am using Pention II Compaq Deskpro.

There is a FAQ posting every sunday here from Pedt Scragg, which
covers this issue.
http://bsn.ch/tp-links
also has a list of articles and "patches".
:-)
--
Franz Glaser, Glasau 3, A-4191 Vorderweissenbach Austria +43-7219-7035-0
Muehlviertler Elektronik Glaser.  Industrial control and instrumentation

http://www.geocities.com/~franzglaser/ http://members.xoom.com/f_glaser/


Wed, 18 Jun 1902 08:00:00 GMT  
 Crt Unit in Turbo Pascal 7.0 generates overflow


Quote:
> Well here is a patch:

[100 lines skipped]

I hope he doesn't have too many files to patch!
Don't you think it would be more helpful to point to a fixed CRT unit
http://www.pedt.demon.co.uk/crt/
which would fix both BP and TP in real and protected mode without having to
modify any source?
But you probably think why to make it simple if it can be made complicated.
___________
Olivier Avenel  SPEC / CEA-Saclay   91191 Gif-sur-Yvette Cedex  France



Wed, 18 Jun 1902 08:00:00 GMT  
 Crt Unit in Turbo Pascal 7.0 generates overflow

Quote:



>> Well here is a patch:
>[100 lines skipped]

>I hope he doesn't have too many files to patch!
>Don't you think it would be more helpful to point to a fixed CRT unit
>http://www.pedt.demon.co.uk/crt/
>which would fix both BP and TP in real and protected mode without having to
>modify any source?

No, I do not point to that, as I am not sure of the legality of that
unit. Also using a different unit can introduce its own bugs or
incompatibilities.

Of course if one has BP then one should edit the source directly.

Quote:
>But you probably think why to make it simple if it can be made complicated.

I have created several ways to fix the bug and I have also responded to
the messages asking advice. This is the first time I get blamed for doing
so.

I do not consider it overwhelming problem to add one unit into each
program that uses CRT.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 Crt Unit in Turbo Pascal 7.0 generates overflow


Quote:

> >Don't you think it would be more helpful to point to a fixed CRT unit
> >http://www.pedt.demon.co.uk/crt/
> >which would fix both BP and TP in real and protected mode without having
to
> >modify any source?

> No, I do not point to that, as I am not sure of the legality of that
> unit. Also using a different unit can introduce its own bugs or
> incompatibilities.
> I have created several ways to fix the bug and I have also responded to
> the messages asking advice. This is the first time I get blamed for doing
> so.

I have the outmost respect for your expert contributions to this group and
thank you heartily for the time you spend helping people.
And I won't start a new, absolutely ridiculous, discussion about the
legality of the replacement CRT unit.
___________
Olivier Avenel  SPEC / CEA-Saclay   91191 Gif-sur-Yvette Cedex  France



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

 Relevant Pages 

1. crt.zip Replacement CRT units for Turbo/Borland Pascal

2. Turbo Pascal for Windows 1.5 - CRT unit

3. Pentium II problem with programs compiled in Turbo Pascal (CRT unit)

4. adler10.zip Adler32 checksum unit for Turbo Pascal 7.0

5. Win95, Turbo Pascal 7.0 and Graph3.tpu-Unit Problem

6. tspa357c.zip Turbo Pascal 7.0 real mode units for (real:-) programmers

7. Borland Pascal 7.0 - Turbo Vision Units

8. sdelay11.zip SuperDelay delay unit for Turbo Pascal 7.0, Allen Cheng

9. pasmouse.zip Mouse unit for Turbo Pascal 7.0, w/src, T.Horatiu

10. tspa3570.zip Turbo Pascal 7.0 real mode units for (real:-) programmers

11. tspa3570.zip Turbo Pascal 7.0 real mode units for (real:-) programmers

12. fsmouse.zip Turbo Pascal 7.0 mouse unit, N.Ehresman

 

 
Powered by phpBB® Forum Software