*help needed re: Divide by 0 error* 
Author Message
 *help needed re: Divide by 0 error*

Hi

My lecturer has told all the students in my programming course that there is
a problem with Turbo Pascal when using uses crt; with computers faster than
200 mhz which results in a "divide by 0 error".

However he neglected to tell us exactly when this problem occurs, and if it
does how to fix it. I cant e-mail him and ask now as he is on Easter
holidays so I would be much obliged if someone could tell me about it.

--
Thanks

Neerav :-]

Webmaster of the Adextinguisher homepage.
Adextinguisher is freeware a banner ad blocking program
located at http://www.*-*-*.com/ ~neeravb/adext



Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*

Quote:
>My lecturer has told all the students in my programming course that there
is
>a problem with Turbo Pascal when using uses crt; with computers faster than
>200 mhz which results in a "divide by 0 error".

This is a bug in the initialization of the CRT unit.

Quote:
>However he neglected to tell us exactly when this problem occurs,

It may happen when both are true:
1) the computer is fast (say, >200MHz)
2) the original CRT unit of Turbo Pascal 7 is used without any patch
   uses crt;

This is a very frequently asked question (VFAQ).
Within two day an expert will reply you in this newsgroup
with a *Sigh* in the beginning of the message.
Please tell your lecturers / colleagues / students about
this, so they don't have to ask again.

Quote:
>and if it does how to fix it.

Try to avoid using CRT, or try the following patches:

Pedt Scragg's patch
http://www.pedt.demon.co.uk/crt/

Also Timo Salmi's FAQ - monthly pointer posted in clpb
ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip
See #124

If you need an official explanation (by INPRISE) of the
bug, see here:
http://www.inprise.com/devsupport/pascal/
It tells you to use search engine to find a patch file.

Please note that, if your computer is 'mission critical',
you should scan any 'executable' patches for viruses.

If you do not want to use any patches at all,
(For example, doing a demo on school's machine once only)
try this:
(UNTESTED, anyway my solution is a very BAD BAD idea)
If you use a multitasking environment (such as Win 9x)
run several programs together with your pascal program,
(these 'dragging programs' need to be started earlier)
As a result your pascal program will run slower, so the
chances of triggering the bug is lower.
(if DELAY is used, the error will still occur, since my 'cheat'
fails very often.)

Quote:
> I cant e-mail him and ask now as he is on Easter
>holidays so I would be much obliged if someone could tell me about it.

Perhaps you should tell him about the patches available when he is back.


Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*


Quote:
> Hi

> My lecturer has told all the students in my programming course that
> there is a problem with Turbo Pascal when using uses crt; with
> computers faster than 200 mhz which results in a "divide by 0 error".

Only with TP/BP 7

Quote:
> However he neglected to tell us exactly when this problem occurs, and
> if it does how to fix it. I cant e-mail him and ask now as he is on
> Easter holidays so I would be much obliged if someone could tell me
> about it.

Read the FAQ posted in this group every Sunday, and download Pedt
Scragg's replacement CRT unit(s), address is in the FAQ.

Robert
--
Robert AH Prins

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



Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*


Quote:

>Hi

>My lecturer has told all the students in my programming course that there is
>a problem with Turbo Pascal when using uses crt; with computers faster than
>200 mhz which results in a "divide by 0 error".

>However he neglected to tell us exactly when this problem occurs, and if it
>does how to fix it. I cant e-mail him and ask now as he is on Easter
>holidays so I would be much obliged if someone could tell me about it.

>--
>Th

DSS.

In addition to what others have said : if you are not allowed to make
the changes necessary to the compiling system, you can always fix the
EXE with Andreas Bauer's TPPATCH - via my pas-time.htm - this couls be
the case if class computers are slow, but you want to give the EXE to
those with faster PCs.

--

 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ;
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ.



Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*
Ok

I've downloaded the patches, but according to what has been suggested I have
another problem, as my Pascal assignment must be submitted as filename.pas,
not a compiled EXE and although I am writing it in TP 5.5, my lecturer is
checking it in TP 7. What approach should I take?

Thanks for suggestions
Neerav



Quote:



> >Hi

> >My lecturer has told all the students in my programming course that there
is
> >a problem with Turbo Pascal when using uses crt; with computers faster
than
> >200 mhz which results in a "divide by 0 error".

> >However he neglected to tell us exactly when this problem occurs, and if
it
> >does how to fix it. I cant e-mail him and ask now as he is on Easter
> >holidays so I would be much obliged if someone could tell me about it.

> >--
> >Th

> DSS.

> In addition to what others have said : if you are not allowed to make
> the changes necessary to the compiling system, you can always fix the
> EXE with Andreas Bauer's TPPATCH - via my pas-time.htm - this couls be
> the case if class computers are slow, but you want to give the EXE to
> those with faster PCs.

> --

MIME. ?
>  <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics &
links;
>  <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal
FAQ;
>  <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b.

mFAQ.


Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*

Quote:
>Ok

>I've downloaded the patches, but according to what has been suggested I have
>another problem, as my Pascal assignment must be submitted as filename.pas,
>not a compiled EXE and although I am writing it in TP 5.5, my lecturer is
>checking it in TP 7. What approach should I take?

Write an explanatory note concerning RTE200 and point out that your
program will work with TP5.5 and TP6 but he will need to patch TP7
to allow him to see your program in that version. Also give him the
references to get the patches himself.

--
Pedt Scragg     http://signpost-design.co.uk/   ODP Editor: http://dmoz.org/
Signpost Web Design, Wrecsam, North Wales



Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*

Quote:

>Ok

>I've downloaded the patches, but according to what has been suggested I have
>another problem, as my Pascal assignment must be submitted as filename.pas,
>not a compiled EXE and although I am writing it in TP 5.5, my lecturer is
>checking it in TP 7. What approach should I take?

Provide an unit that fixes it. You should not need to document the unit
beyond mentioning what it is for. Make sure that the unit causes no harm
in TP before 7.0 (conditional compiling)

Requiring  some separate patching is IMO not acceptable. Here is one
fix that consists of two units:

Unit RT200fix;

interface

uses RT200Sub,crt,dos;

implementation

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

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

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.

There is a third that fixes the delay but I have not included it as it
is not relevant to the problem you have (otherwise using TP 5.5 would
be out of the question)

You could even make the second unit simpler if the delay is not needed
to be correct:

Unit RT200Sub;            

interface

Var int0Save:pointer;

implementation

{$ifdef msdos}
{$ifdef ver70}

uses dos;

Procedure Int0; assembler;
          asm
          mov dx,54       { Maximum OK DX:AX }
          mov ax,65535
          iret            { return to the DIV (286+) }
          end;

begin
  GetIntVec(0,Int0Save);

{$endif}
{$endif}
end.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*

Neerav heeft geschreven in bericht

Quote:
>Ok

>I've downloaded the patches, but according to what has been
suggested I have
>another problem, as my Pascal assignment must be submitted as
filename.pas,
>not a compiled EXE and although I am writing it in TP 5.5, my
lecturer is
>checking it in TP 7. What approach should I take?

I think you have nothing to worry about.
If your EXE works well in TP5.5, your PAS file should compile OK
in TP7.

Huub.



Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*

Quote:


>> another problem, as my Pascal assignment must be submitted as
>> filename.pas, not a compiled EXE and although I am writing it in TP 5.5,
>> my lecturer is checking it in TP 7. What approach should I take?
> Provide an unit that fixes it.

If the code is being turned in as source, and the instructor has his own
compiler, then I'm sure _he_ can worry about that side of it. It will
either work for all his students' programs, or none of them (or rather,
none of those that use the CRT unit). I don't see the point in the student
attempting to deal with the RTE 200 problem.

Neerav: If you don't mind help in French, consider downloading TP 7.01 from
the Borland/France site, so as to be in sync with your teacher.

--



Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*

Quote:


>> another problem, as my Pascal assignment must be submitted as
>> filename.pas, not a compiled EXE and although I am writing it in TP 5.5,
>> my lecturer is checking it in TP 7. What approach should I take?
> Provide an unit that fixes it.

If the code is being turned in as source, and the instructor has his own
compiler, then I'm sure _he_ can worry about that side of it. It will
either work for all his students' programs, or none of them (or rather,
none of those that use the CRT unit). I don't see the point in the student
attempting to deal with the RTE 200 problem.

Neerav: If you don't mind help in French, consider downloading TP 7.01 from
the Borland/France site, so as to be in sync with your teacher.

--



Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*

Quote:
> I think you have nothing to worry about.
> If your EXE works well in TP5.5, your PAS file should compile OK
> in TP7.

Not in the context of the CRT unit and RTE 200. The program will work in 5.5
because the RTE 200 error does not occur with the TP 5.5 CRT unit. When
compiled under TP 7.0, the linker will link in the newer CRT unit, which
contains the RTE 200 bug, and therefore the program will fail to run.

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will

______________________________|_______________________________________



Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*


Quote:


>> I think you have nothing to worry about.
>> If your EXE works well in TP5.5, your PAS file should compile OK
>> in TP7.

>Not in the context of the CRT unit and RTE 200. The program will work in 5.5
>because the RTE 200 error does not occur with the TP 5.5 CRT unit. When
>compiled under TP 7.0, the linker will link in the newer CRT unit, which
>contains the RTE 200 bug, and therefore the program will fail to run.

In addition, I would expect any TP5.5 program using BREAK or CONTINUE as
variables to be deemed unsatisfactory by a TP7-compatible lecturer.

--

 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ;
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ.



Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*


Quote:

>In addition, I would expect any TP5.5 program using BREAK or CONTINUE as
>variables to be deemed unsatisfactory by a TP7-compatible lecturer.

Why would it be? One can override predefined identifiers in Pascal.
Break and Continue are procedures, not reserved words.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*
Hi Everyone

Thanks for the responses, I've checked with the lecturer and he has now
patched Turbo Pascal 7.0 on the University computer network so my code now
compiles on them fine.

Neerav


Quote:


> >In addition, I would expect any TP5.5 program using BREAK or CONTINUE as
> >variables to be deemed unsatisfactory by a TP7-compatible lecturer.

> Why would it be? One can override predefined identifiers in Pascal.
> Break and Continue are procedures, not reserved words.

> Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 *help needed re: Divide by 0 error*

Quote:
>Hi Everyone

>Thanks for the responses, I've checked with the lecturer and he has now
>patched Turbo Pascal 7.0 on the University computer network so my code now
>compiles on them fine.

Good, glad you got a successful conclusion.
--
Pedt Scragg     http://signpost-design.co.uk/   ODP Editor: http://dmoz.org/
Signpost Web Design, Wrecsam, North Wales


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 16 post ]  Go to page: [1] [2]

 Relevant Pages 

1. divide by zero error/mathmatic overflow error?

2. divide by 0 error/arithmetic overflow error?

3. uses crt; divide by zero error

4. Divide by Zero CRT Error

5. Divide by Zero error

6. Pascal_7.0_in_Pentium_II : Divide by zero error

7. divide by zero error when using CRT;

8. TP ver7, error 200 (divide by zero), with real mode programs

9. rdelay10.zip Prevent the divide-by-0 Crt error on fast machines

10. Divide by 0 Error on Ini when using Pentium 200

11. D3 - Divide By Zero Error on Post...

12. Catching maths errors (eg divide by zero)

 

 
Powered by phpBB® Forum Software