Turbo Pascal

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Turbo Pascal
Developer(s) Anders Hejlsberg while working at Borland
Initial release 1983; 32 years ago (1983)[1]
Operating system CP/M, CP/M-86, DOS,
Windows 3.x, Macintosh
Platform 8080/Z80, 8085, x86
Type Integrated development environment

Turbo Pascal is a software development system that includes a compiler and an integrated development environment (IDE) for the Pascal programming language running on CP/M, CP/M-86, and DOS, developed by Borland under Philippe Kahn's leadership. From version 6 both a lower-priced Turbo Pascal and more expensive Borland Pascal were produced; Borland Pascal had more libraries and standard library source code. The name Borland Pascal is also used more generically for Borland's dialect of Pascal.

Borland has released three old versions of Turbo Pascal free of charge because of their historical interest: the original Turbo Pascal (now known as 1.0), and versions 3.02 and 5.5 for DOS.[2][3][4]

Motivation and release[edit]

Philippe Kahn first saw an opportunity for Borland, his newly formed software company, in the field of programming tools. Historically, the vast majority of programmers saw their workflow in terms of the edit/compile/link cycle, with separate tools dedicated to each task. Programmers wrote source code and entered it using a text editor, a compiler then created object code from source (often requiring multiple passes), and a linker combined object code with runtime libraries to produce an executable program.

In the early IBM PC market (1981–83) the major programming tool vendors all made compilers that worked in a similar fashion. For example, the Microsoft Pascal system consisted of two compiler passes and a final linking pass (which could take minutes on systems with only floppy disks for secondary storage). This process was the cumbersome product of the extremely limited resources of the early IBM PC models. Vendors of software development tools aimed their products at professional developers, and the price for these basic tools plus ancillary tools like profilers ran into the hundreds of dollars.

Kahn's idea was to package all these functions in an integrated programming toolkit, have it run with much better performance, and charge one low price for it all. Instead of selling the kit through established sales channels (retailers or resellers), his new tool would be sold inexpensively via mail-order.

As an added selling point against the bigger vendors, Turbo Pascal disks had no copy protection. Turbo Pascal came with the famous "Book License": "You must treat this software just like a book ... [it] may be used by any number of people ... may be freely moved from one computer location to another, so long as there is no possibility of it being used at one location while it's being used at another."[5]


Jerry Pournelle of BYTE wrote in February 1984 that Turbo Pascal "comes close to what I think the computer industry is headed for: well documented, standard, plenty of good features, and a reasonable price". Pournelle disliked the requirement to buy another license to distribute binaries, but noted that "it turns out not to be a lot more. Borland only wants another $100" more than the $49.95 base price, and that "my first impression of Turbo is that it's probably worth $149.95. It looks to do everything MT+ with the Speed Programming Package does, and maye even do it faster and better".[6] Three BYTE reviewers praised Turbo Pascal in July 1984. One called the DOS version "without doubt, the best software value I have ever purchased", and another called the CP/M version "an excellent product ... [Borland] deserves praise for this high-value product". The third stated that it was "not a good compiler for developing massive applications", but added that it was greatly superior to BASIC. He concluded that Turbo Pascal was "a bargain that shouldn't be passed up".[7] Bruce Webster also praised the language in the magazine, stating in August 1985 that Turbo Pascal "is best known for its small size, incredible compile speeds, and fast execution times". It noted that the software's quality and low price had been especially surprising after the "JRT Pascal fiasco", and stated that even at the new higher $69.95 price, version 3.0 was "probably still the best software deal on the market".[8]

PC Magazine was similarly complimentary in November 1984, stating that "nothing like Turbo Pascal has ever existed for PC-DOS before". It praised the software's low price, speed, unusually good documentation for a compiler, and noted the existence of many utilities from other companies that hoped to benefit from Turbo Pascal's popularity. The review stated that the IDE that simplified the edit-compile-run-debug loop made Turbo Pascal accessible to new programmers like BASIC.[9]

Borland sold about 250,000 copies of Turbo Pascal in two years, which BYTE described as "an amazing figure for a computer language".[8]

CP/M and DOS versions[edit]

Turbo Pascal 3.0 manual front cover

The Turbo Pascal compiler was based on the Blue Label Pascal compiler originally produced for the NasSys cassette-based operating system of the Nascom microcomputer in 1981 by Anders Hejlsberg. Borland licensed Hejlsberg's "PolyPascal" compiler core (Poly Data was the name of Hejlsberg's company in Denmark), and added the user interface and editor. Anders Hejlsberg joined the company as an employee and was the architect for all versions of the Turbo Pascal compiler and the first three versions of Borland Delphi.[2]

The compiler was first released as Compas Pascal for CP/M, and then released on November 20, 1983 as Turbo Pascal for CP/M (including Apple II computers fitted with Z-80 SoftCards, Commodore 64s with CP/M cartridge, and the DEC Rainbow), CP/M-86, and MS-DOS machines. On its launch in the United States market, Turbo Pascal retailed for USD49.99, a very low price for a compiler at the time. The integrated Pascal compiler was of good quality compared to other Pascal products of the time.[10]

The Turbo name alluded to the speed of compilation and of the executables produced. The edit/compile/run cycle was fast compared to other Pascal implementations because everything related to building the program was stored in RAM, and because it was a one-pass compiler written in assembly language. Compilation was very quick compared to that for other languages (even Borland's own later compilers for C),[citation needed] and programmer time was also saved since the program could be compiled and run from the IDE. The speed of these COM executable files was a revelation for developers whose only prior experience programming microcomputers was with interpreted BASIC or UCSD Pascal, which compiled to p-code.

The program required a computer running MS-DOS, CP/M, or CP/M-86 with 64 kB of memory and a floppy drive, typically an Apple ][ with a CP/M card and a single 140 kB floppy drive, or a PC with a 160 kB drive. The installer, lister, and compiler with its IDE, along with a demonstration program (in the form of source code for a simple spreadsheet called MicroCalc and written by Philippe Kahn himself), would fit on a single floppy disc. If the demonstration program was deleted, there was sufficient space for the typical user's source code and compiled executable. As it was common at the time for users to have only one floppy drive (and no hard drive), it was a great convenience to be able to fit the compiler and the program being written on a single disc.

Bill Gates saw the success of Turbo Pascal "in very personal terms, and 'couldn't understand why [Microsoft's] stuff was so slow. He would bring in poor Greg Whitten [programming director of Microsoft languages] and yell at him for half an hour.' He couldn't understand why Kahn had been able to beat an established competitor like Microsoft."[11]

The IDE was very advanced for its day, when computing resources on the IBM PC were very limited (IBM's PC design having been "prudently" constrained so that its performance would not compete with IBM's profitable enterprise products).[12] The IDE was simple and intuitive, and had a well-organized system of menus. Early versions of the editor used WordStar key functions, which was the de facto standard at the time. Later versions of the IDE, designed for PCs with more disk space and memory, could display the definitions of the keywords of the language by putting the cursor over a keyword and pressing the F1 key. The definitions also frequently included example code.

The .COM format let programmers write Terminate and Stay Resident programs, small utilities that stayed in memory and let the computer do other tasks, something very popular in the days before multitasking systems such as Microsoft Windows. Borland itself produced a small application suite called Sidekick that was a TSR letting the user keep a diary, notes, and so forth.

Versions 2-7[edit]

Versions 2 and 3 were incremental improvements to the original Turbo Pascal, a basic all-in-one system, working in memory and producing .COM executable files for DOS and CP/M, and equivalent .CMD executables for CP/M-86 (not the same as .CMD batch files used in 32-bit Microsoft Windows).[3] Source code files were limited to 64KB to simplify the IDE, and DOS .COM files were limited to 64KB each of code, Stack and Global (static) variables for the same reason. Program source code could be extended by the use of Included files, and the .COM programs could be extended by the use of overlays.

Version 4, released in 1987, was a major rewrite of the whole system, and versions 5 to 7 were incremental improvements and expansions. The compiler generated executables in .EXE format under DOS, rather than the simpler but more restricted .COM executables. The by-then obsolete CP/M and CP/M-86 operating system versions were dropped. Version 4 also introduced units, and a full-screen text user interface with pull-down menus; earlier versions had a text-based menu screen and a separate full-screen editor. (Microsoft Windows was still very experimental when the first version was released, and even mice were rare.)

Version 5.0 introduced the Borland blue screen, used by Borland's DOS compilers until the end of this product line in the mid-1990s.

Later versions came in two packages with the same version number: a less expensive "Turbo" package, and a "Borland" package with enhanced capabilities and more add-ons.

Assembly language[edit]

While all versions of Turbo Pascal could include inline machine code, later versions had the ability to easily integrate assembly language within Pascal.

Support for the 8086 memory model was provided by inline assembly, compiler options, and language extensions such as the "absolute" keyword. The Turbo Assembler, TASM, was supplied with the enhanced "Borland Pascal" versions. At the time the most-used assembler was Microsoft's MASM; TASM was designed with a switch either to assemble code written for MASM, replicating MASM's perceived "quirks", or to use a native "Ideal" mode claimed to be better.

Debugging and profiling[edit]

The IDE provided several debugging facilities, including single stepping, examination and changing of variables, and conditional breakpoints. In later versions assembly-language blocks could be stepped through. The user could add breakpoints on variables and registers in an IDE window. Programs using IBM PC graphics mode could flip between graphics and text mode automatically or manually, or display both on two screens. For cases where the relatively simple debugging facilities of the IDE were insufficient, Turbopower Software produced a more powerful debugger, T-Debug.[13] The same company produced Turbo Analyst and Overlay Manager for Turbo Pascal. T-Debug was later updated for Turbo Pascal 4, but discontinued with the release of Borland's Turbo Debugger (TD), which also allowed some hardware intervention on computers equipped with the new 80386 processor.

TD was usually supplied in conjunction with the Turbo Assembler and the Turbo Profiler, a code profiler that reported on the time spent in each part of the program so that attention could be paid to optimising where it was most needed.[14] The books included with Borland Pascal had detailed descriptions of the Intel assembler language, including the number of clock cycles required by each instruction. Development and debugging could be carried out entirely within the IDE unless the advanced debugging facilities of Turbopower T-Debug, and later TD, were required.

Later versions also supported remote debugging via an RS232 communication cable.[15]


Over the years, Borland enhanced not only the IDE, but also the programming language, since ISO standard Pascal requires implementation-specific additions to be used for real-world application development. Standard Pascal is designed to be platform-independent, so provides no low-level access to hardware- or operating system-dependent facilities. Standard Pascal also does not prescribe how a large program should be split into separate compilation units. From version 4, Turbo Pascal adopted the concept of units from UCSD Pascal. Units were used as external function libraries, like the object files used in other languages such as FORTRAN or C.

For example the line uses crt; in a program included the unit called crt; the uses is the mechanism for using other compilation units. interface and implementation were the keywords used to specify, within the unit, what was (and what was not) visible outside the unit. This is similar to the public and private keywords in other languages such as C++ and Java.

Units in Borland's Pascal were similar to Modula-2's separate compilation system. In 1987, when Turbo Pascal 4 was released, Modula-2 was making inroads as an educational language which could replace Pascal. Borland, in fact, had a Turbo Modula-2 compiler, but this product ran only on CP/M and was never ported to DOS (its user interface was almost identical to that of Turbo Pascal 1–3). Instead of porting their Modula-2 compiler to DOS, Borland chose to implement separate compilation in their established Pascal product.

Separate compilation was not part of the standard Pascal language, but was already available in UCSD Pascal, which was very popular on 8-bit machines. Turbo Pascal syntax for units appears to have been borrowed from UCSD Pascal.[16] Earlier versions of Turbo Pascal, designed for computers with limited resources, had no real need for it (the language had a statement to include separate source code in a program when necessary) but, as computing and storage facilities advanced and the ability to generate large EXE files was added to Turbo Pascal, programs became large and complex enough to benefit from separate compilation.

Object-oriented programming[edit]

From version 5.5 some object-oriented programming features were introduced: classes, inheritance, constructors and destructors.[4] The IDE was already augmented with an object browser interface showing relations between objects and methods and allowing programmers to navigate the modules easily. Borland called its language Object Pascal, which was greatly extended to become the language underlying Delphi (which has two separate OOP systems). The name "Object Pascal" originated with the Pascal extensions developed by Apple Inc. to program its Lisa and Macintosh computers. Pascal originator Niklaus Wirth consulted in developing these extensions, which built upon the record type already present in Pascal.

Windows versions[edit]

Two versions named "Turbo Pascal for Windows" (TPW), for Windows 3.x, were released: TPW 1.0, based on Turbo Pascal 6 but released about 2 years later, and 1.5, released after Turbo Pascal 7; they were succeeded by Borland Pascal 7, which had Windows support. The Windows compiler in Pascal 7 was titled Borland Pascal for Windows'.

Both versions built Windows-compatible programs, and featured a Windows-based IDE, as opposed to the DOS-based IDE in Turbo Pascal. The IDE and editor commands conformed to the Microsoft Windows user interface guidelines instead of the classic TP user interface. The support for Windows programs required the ObjectWindows library, similar but not identical to that for the first release of Borland C++, and radically different from the earlier DOS Turbo Vision environment. Turbo Pascal was superseded for the Windows platform by Delphi; the Delphi compiler can produce console programs in addition to GUI applications, so that the use of Turbo and Borland Pascal became unnecessary.

Apple Macintosh[edit]

Borland released Turbo Pascal for Macintosh in 1985. Much like versions 1 to 3 for other operating systems, it was written in compact assembly language and had a very powerful IDE, but no good debugger. Borland did not support this product very well, although they issued a version 1.1, patched to run on the 32-bit Macintosh II. Macintosh support was dropped soon after.


By 1995 Borland had dropped Turbo/Borland Pascal and replaced it with the rapid application development (RAD) environment Delphi, based on Object Pascal. The 32-bit Delphi versions still support the more portable Pascal enhancements of the earlier products (i.e. those that are not specific to 16-bit code) including the earlier static object model.

Other suppliers have produced software development tools compatible with Turbo Pascal. The best-known are Free Pascal and Virtual Pascal.

Freeware release[edit]

Borland released several versions of Turbo Pascal as freeware after they became "antique software" (Abandonware) in 2002.[17] The newest released international version was TP 5.5, while the newer French TP 7.01 was also released as freeware.[18] The downloads are still available on the successor website of Embarcadero Technologies.[2][3][4]

In education[edit]

Borland Pascal is still taught in some countries at secondary, sixth form and university levels. It is taught at colleges and universities in Costa Rica, Turkey, Germany, USA, Malta and at secondary schools in Argentina, Jamaica, Belgium, Bulgaria, Costa Rica, Croatia, Moldova, Romania, Serbia, Libya, Tunisia, France, Vietnam, Canada and Ukraine. It was the state-approved educational programming language for all South African secondary schools until 2002. Today it continues to be taught in some universities around the world as an introduction to computer programming, usually advancing to C or Java or both.

Some lecturers prefer to use Borland Pascal 7 or Turbo Pascal 5.5 because of its simplicity in comparison to more modern IDEs such as Microsoft Visual Studio or Borland JBuilder, so it introduces students unfamiliar with computing to common tasks such as using the keyboard and keyboard shortcuts (TP 5.5 has no mouse support), familiarises them with DOS commands (which are largely the same as those of Microsoft Windows's command prompt), and lets them write programs without too much worry about simply getting the environment to work. TP 5.5 is legally available as a free download from Borland.[17][18]

Issue with CRT unit on fast processors[edit]

Several versions of Turbo Pascal, including the latest version 7, include a CRT unit used by many fullscreen text mode applications. This unit contains code in its initialisation section to determine the CPU speed and calibrate delay loops. This code fails on processors with a speed greater than about 200 MHz and aborts immediately with a "Runtime error 200" message.[19] (the error code 200 had nothing to do with the CPU speed 200 MHz; it was just a coincidence). This is caused because a loop runs to count the number of times it can iterate in a fixed time, as measured by the real-time clock. When Turbo Pascal was developed it ran on machines with CPUs running at 1 to 8 MHz, and little thought was given to the possibility of vastly higher speeds, so at about 200 MHz the 16-bit counter overflows.[20] Several patches have been required as processor speeds increased.

Programs compiled with this error can be recompiled with a compiler patched to eliminate this error (using a TURBO.TPL itself compiled with a corrected CRT unit) or, if source code is not available, executables can be patched by a tool named TPPATCH or equivalent,[21] or by loading a Terminate and Stay Resident program loaded before running the faulty program.[22]

There are also patches to the TP7 compiler itself,[23] thus if the Pascal source is available, a new compilation's code will work without the compiled code having to be patched. If the source code is available, porting to libraries without CPU clock speed dependency is a solution too.[24]

Floating point[edit]

There were several floating-point types, including single (the 4-byte [IEEE 754] representation) double (the 8-byte IEEE 754 representation), extended (a 10-byte IEEE 754 representation used mostly internally by numeric coprocessors) and Real (a 6-byte representation).

In the early days, Real was the most popular. Many PCs did not have a floating point coprocessor so all FP had to be done in software. Borland's own FP algorithms on Real were quicker than using the other types, though its library also emulated the other types in software.

Sample code[edit]

  • Pascal is not case sensitive.
  • Historically, Pascal comments are enclosed { within pairs of braces }, or (* left parenthesis/asterisk and asterisk/right parenthesis pairs *), and these can span any number of lines. Later versions of Borland Pascal also supported C++-style comments // preceded by two forward slashes , which finish at the end of the line.
  • The syntax for the statement case is more flexible than standard Pascal.
  • Sets may only have up to 256 (28) members.
  • Standard, fixed-length Pascal strings are supported, but there is also a more flexible String type.

This is the classic Hello world program in Turbo Pascal:

program HelloWorld;
  WriteLn('Hello World')

This asks for a name and writes it back to the screen a hundred times:

program WriteName;
  i    : Integer;        {variable to be used for looping}
  Name : String;         {declares the variable Name as a string}
  Write('Please tell me your name: ');
  ReadLn(Name);          {ReadLn returns the string entered by the user}
  for i := 1 to 100 do
    WriteLn('Hello ', Name)

See also[edit]


  1. ^ Gajic, Zarko. "Delphi History– from Pascal to Borland Developer Studio 2006". About.com. 
  2. ^ a b c Intersimone, David (2000-02-01). "Antique Software: Turbo Pascal v1.0". Embarcadero Technologies. 
  3. ^ a b c Intersimone, David (2000-02-10). "Antique Software: Turbo Pascal v3.02". Embarcadero Technologies. 
  4. ^ a b c Intersimone, David (2002-02-21). "Antique Software: Turbo Pascal v5.5". Embarcadero Technologies. 
  5. ^ Google Groups
  6. ^ Pournelle, Jerry (February 1984). "Chaos Manor Gets Its Long-Awaited IBM PC". BYTE. p. 113. Retrieved 8 February 2015. 
  7. ^ Wadlow, Tom; Pierce, Al; Bridger, Mark (July 1984). "Turbo Pascal". BYTE (review). pp. 263–278. Retrieved 23 October 2013. 
  8. ^ a b Webster, Bruce F. (August 1985). "Greetings and Agitations". BYTE. p. 355. Retrieved 27 October 2013. 
  9. ^ Duntemann, Jeff (1984-11-13). "Supercharged Turbo Pascal". PC Magazine. p. 276. Retrieved 25 October 2013. 
  10. ^ Chapman, Merrill R. (2006). In Search of Stupidity: Over 20 Years of High-Tech Marketing Disasters. Springer-Verlag. p. 118. ISBN 978-1-59059-721-7. Borland made its debut in the industry in a big way with the release of Turbo Pascal in November 1983. Turbo Pascal was a port to DOS and CP/M of Anders Hejlsberg's COMPAS Pascal, and it was released by Borland at a price that seemed amazing at that time: $49.95, about one-tenth the price of comparable products. 
  11. ^ Wallace, James; Erickson, Jim (1992). "Growing Pains". Hard Drive: Bill Gates and the Making of the Microsoft Empire. John Wiley & Sons. p. 277. ISBN 0-471-56886-4. 
  12. ^ Chposky, James; Leonsis, Ted (1988). Blue Magic: The People, Power and Politics Behind the IBM Personal Computer. New York, Oxford: Facts on File (Infobase Publishing). pp. 23–24. ISBN 0-8160-1391-8. 
  13. ^ InfoWorld 21 Mar 1988: Announcement of Turbopower T-Debug 4
  14. ^ Turbo Profiler 1.0 manual
  15. ^ Marco Cantų's Delphi Power Book: Debugging Delphi Programs
  16. ^ 3.3.2. Linkage to Externally Compiled and Assembled Routines – UCSD Pascal System II.0 User Manual Reconstruction – Version I.5, September 1978
  17. ^ a b "Antique Software: Turbo Pascal v5.5". CDN » Museum. Borland Software Corporation. Archived from the original on 2004-02-03. Retrieved 2013-04-01. 
  18. ^ a b "Téléchargements - Gratuits : Compilateurs Delphi, Pascal & C / C++". Borland Software Corporation. 2002-05-02. Archived from the original on 2003-08-13. Note to internationnal users : This free Turbo Pascal 7 is available in French Only. The US version of Turbo Pascal 7 is not available as free download yet. For the US version please download Turbo Pascal 5.5 US below. Thanks. 
  19. ^ "Borland Pascal Developer Support". Retrieved 2011-04-25. 
  20. ^ "Borland's Version 7 Pascals' Start-Up Runtime Error 200 (divide by zero)". Retrieved 2012-01-04. 
  21. ^ "PatchCRT – fix RunTime Errors on some apps". kennedysoftware.com. 2003. Retrieved 2010-09-28. 
  22. ^ "How to fix a Run Time Error 200". pcmicro.com. 2006. Retrieved 2010-09-28. 
  23. ^ "Runtime Error 200". blume-programm.de. 2003-03-13. Retrieved 2010-09-28. 
  24. ^ Cheng, Allen (1997). "SuperDelay v1.1a". blume-programm.de. Retrieved 2010-09-28. 

External links[edit]