Solved

error "Division by zero"

Posted on 1998-09-22
5
500 Views
Last Modified: 2010-04-16
Declaring  unit CRT("uses CRT;") cause my program error "Division by zero" when running.(not in compling)
declare other units don't cause that error.
Thanks.
0
Comment
Question by:tungsim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 2

Accepted Solution

by:
omsec earned 100 total points
ID: 1215678
You are probly using a PII-Processor huh?
We heard that problem often. Just get a fixed Version of the CRT-Unit.

http://garbo.uwasa.fi/pc/turbspec.html.

if you want other URLs, or CRT.PAS (unit's source) let me know ;)
0
 
LVL 7

Expert Comment

by:Motaz
ID: 1215679
Your computer seem to be very fast.. so that CRT unit cann't run on it... I think there is updated CRT unit can solve this problem but I don't know exactly where is it.

Motaz from Sudan.
motaz1@yahoo.com
0
 
LVL 7

Expert Comment

by:Motaz
ID: 1215680
Right Omsec, that is what I mean.. Thanks..
Motaz.
0
 
LVL 1

Expert Comment

by:lewis_loo
ID: 1215681
My friend also get the same problem with you, but he don't used pentium II processor only about Pentium 200 MMX the oldest one? How about that? he used Windows 98 as his operating system. is that a problem in Windows 98?
0
 
LVL 3

Expert Comment

by:vikiing
ID: 1215682
During initialization phase of the program, CRT unit tries to evaluate a time-base in order to have a proper delay value to deal with Delay() procedure. That is accomplished by counting hoy many times an integer value is increased during one millisecond of time.

In faster processors, since approximately 300 MHz os more, that gives as a result a value greater than 65535, which is greater enough to cause on overflow condition, which is interpreted as a "Division by zero" by initializing routine, thus avoiding the program to run.

The (partial) solution) I've found is to patch the object code of the CRT unit in order to modify this instruction:

       DIV  CX,37h     ; Divide by 55 (dec.), the quantity of
                       ; times the system clock interrupts, at
                       ; 1/18 of a second

by this one:

       DIV  CX,226h    ; Divide by 550 (dec.)

That avoids the overflow; but the subtle effect is that the so-obtained base-time is 10 times smaller. Thus, every time the Delay() procedure is used, it's argument must be 10 times greater to achieve the same results, i.e.:

        Delay(x);

must be changed by

        Delay(x*10);

For a softwre developer, it's not so terrible. There's another  solution, in which the program itself (using the patched CRT unit) can disregard the use of CRT's Delay() procedure, but programmer has to write its own code to get the right time-base (I've done it) the get the same results without having to multiply by 10 the argument.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Getting to know the threat landscape in which DDoS has evolved, and making the right choice to get ourselves geared up to defend against  DDoS attacks effectively. Get the necessary preparation works done and focus on Doing the First Things Right.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question