flipCode - Tech File - Alex Champandard [an error occurred while processing this directive]
Alex Champandard
Click the name for some bio info

E-Mail: alex@base-sixteen.com



   07/12/1999, Leftovers From The Contest: Fixing TP7's Runtime Error 200 bug


As a demo coder, it is fair to assume that any viewer with a 3D card is capable of setting up his OpenGL drivers :) But you can't expect them to underclock their processors to make Turbo Pascal 7 programs run without crashing... A couple of entries had that problem.

The problem is that TP7 can't handle quick processors, like the Pentium II and above. For programs that include the CRT unit, a certain number of instructions are executed on startup, to determine the overall performance of the PC. The Pentium II does these instructions so quickly that TP7 measures this time as being ZERO. So when it wants to find the speed coefficiant, by dividing by the time, the program crashes with a fatal Runtime Error #200: Divide by Zero.

A simple hack is to increase the number of instructions to be timed, so that the time taken to execute them is not zero.

In each executable, the following byte sequence corresponds to the critical part of the program:

                            f7h d0h f7h d2h b9h 37h 00h


The 37h is the value that needs replacing. So with your favourite hexadecimal editor, simply replace that string with the following:

                            f7h d0h f7h d2h b9h a0h 00h

This will fix all bad .EXE files.

But if you actually use TP7 to compile programs, you can fix TURBO.TPL in the same way, so that all generated .EXE files will be clean.

Click here to download a simple program that does this for you, to save you some hassle with hexadecimal editors.





  • 01/05/2002 - A.I., Websites and Voxels
  • 03/05/2001 - State Of The Art Character Animation
  • 01/24/2001 - Alternate Programming Languages
  • 01/11/2001 - The Sound Of Silence
  • 09/20/2000 - Engine prototypes, yet more landscape LOD and hard body physics
  • 07/13/2000 - Good Practice (TM)
  • 06/13/2000 - Revision Week Indeed
  • 04/11/2000 - Escape From Inactivity ;)
  • 01/05/2000 - Generic Shaders
  • 12/03/1999 - Start Of Term: Lots Of Good Intensions :)
  • 10/06/1999 - Dynamic LOD, Landscape Generation and much more...
  • 09/22/1999 - Water Contest Entry: Rendering Raytraced Refraction with 3D Hardware
  • 09/16/1999 - More About Bezier Patches And Fractals
  • 08/11/1999 - The Right Landscape Engine For You!
  • 07/12/1999 - Leftovers From The Contest: Fixing TP7's Runtime Error 200 bug
  • 07/01/1999 - Introduction

  • This document may not be reproduced in any way without explicit permission from the author and flipCode. All Rights Reserved. Best viewed at a high resolution. The views expressed in this document are the views of the author and NOT neccesarily of anyone else associated with flipCode.

    [an error occurred while processing this directive]