
Pascal Compilers
This document will explain the purpose and usage of compilers as
well as provide links to well-known Pascal compilers. If you
are already familiar with what compilers are, you can
skip to the Free Pascal download section.
About Computer Languages and Compilers
When talking about computer languages, there are basically three
major terms that will be used.
- Machine language -- actual binary code that gives basic instructions to
the computer's CPU. These are usually very simple commands like adding
two numbers or moving data from one memory location to another.
- Assembly language -- a way for humans to program computers directly
without memorizing strings of binary numbers. There is a one-to-one
correspondance with machine code. For example, in Intel x86 machine
language, ADD and MOV are mnemonics for the addition
and move operations.
- High-level language -- permits humans to write complex programs
without going step-by step. High-level languages include Pascal, C,
C++, FORTRAN, Java, BASIC, and many more. One command in a high-level
language, like writing a string to a file, may translate to dozens
or even hundreds of machine language instructions.
All computers can only run machine language programs directly. Assembly
language programs are assembled, or translated into machine language.
Likewise, programs written in high-level languages, like Pascal, must
also be translated into machine language before they can be run. The
technical terminology for this operation is compiling.
The program that accomplishes the translation is called a compiler.
This program is rather complex since it not only creates machine language
instructions from lines of code, but often also optimizes the code to
run faster, adds error-correction code, and links the code with subroutines
stored elsewhere. For example, when you tell the computer to print something
to the screen, the compiler translates this as a call to a pre-written
module. Your code must then be linked to the code that the compiler
manufacturer provides before an executable program results.
With high-level languages, there are again three terms to remember:
- Source code -- the code that you write. This typically
has an extension that indicates the language used. For example,
Pascal source code usually ends in ".PAS" and C++ code usually ends
in ".CPP"
- Object code -- the result of compiling. Object code usually
includes only one module of a program, and cannot be run yet since
it is incomplete. On DOS/Windows systems, this usually has an
extension of ".OBJ"
- Executable code -- the end result. All the object code modules
necessary for a program to function are linked together. On DOS/Windows
systems, this usually has an extension of ".EXE"
More About Compilers
The de facto standard in compilers is Borland Pascal.
A long time ago, most Pascal compilers were clumsy and slow, strayed far from
the Pascal standard, and cost several hundred dollars. In 1984,
Borland introduced Turbo Pascal, which sold for less than $100.
This product was an instant success. However, in 1993, the last
version of Turbo Pascal,
version 7 for DOS, came out. After that, the demand for DOS
programs plummetted and Borland (now renamed Inprise) focused
on producing Windows compilers.
This tutorial will only deal with console-based programming, where
the computer prints lines of data to the screen and the user
interact with the program using a keyboard. The goal of the tutorial
is to teach how to program in Pascal. Once you've learned
that, you can easily look at a reference book or another web page
and pick up graphics and windowing systems on your own. Thus,
old version of Borland Pascal will work fine. For example, you
can visit the Borland
Museum to download an old copy of Borland Pascal. The latest
free version available is 5.5.
Because of Borland's dominance in the market, there are few other
commercial Pascal compilers for DOS/Windows computers. There,
are however, some shareware and freeware compilers. Check
The
Open Directory category on Pascal Compilers for more
information.
For non-DOS computers, there are also very few commercial compilers.
Metrowerks, until very
recently, supported Pascal in its flagship product for Macintosh
computers, Metrowerks Codewarrior. However, Codewarrior now
concentrates on C, C++, and Java. If you have a Macintosh computer,
you can grab an old copy of Symantec Think Pascal, which is about
as old as Borland Pascal (as seen by the fact that it produces 68k
code rather than PowerPC code). See
The
Free Country's Free Pascal Compiler List for more information.
Several varieties of UNIX, including Linux, include C, C++, FORTRAN,
and Pascal compilers. The Pascal compiler on UNIX is generally
named "pc." This will be good enough for you to learn Pascal with,
but it is very limited in terms of power and you will quickly outgrow
it.
Download Free Pascal
The open-source revolution started with Linux has yielded a superb
free Pascal compiler as well. This compiler has versions for the
Linux, DOS, OS/2, Win32, and Amiga platforms. Free Pascal is
mostly compatible with Borland Pascal in syntax, and is much more
useful since you can take your code to so many different platforms.
Useful pages at the Free Pascal site:
I suggest downloading the compiler in one big package unless you
pay for timed Internet access. This takes a while, but it has
the virtue of making it very simple to install and giving you
all the parts of the compiler, including optional example code.
Installation is relatively straightforward. For DOS, OS/2, and Windows,
simply unZIP the ZIP file that you downloaded and run the INSTALL program.
For Linux, if you downloaded the big package, you can also simply run
INSTALL. If you downloaded the Red Hat or Debian packages,
you'll need to run your Linux distribution's package manager.
If you got the tarball, you'll need to compile the compiler
yourself. As for Amiga, the number of Amigas out there is
very small, limited mostly to Amiga enthusiasts, since no
Amigas have been built in about a decade. If you're an
Amiga enthusiast, chances are you know a lot about computers
already and don't need any help to install the compiler.
|