Operating instructions

Why a PET, APPLE, 6502 BASIC
Compiler? A Simple Explanation
BASIC, on almost all
6502
microcomputers, is run with
an Interpreter. A more efficient method
of
running
BASIC
is
through a Compiler. This article discusses
what a Compiler is, how
it
works, and discusses a
BASIC Compiler currently under development.
Bruce
M.
Beach
Horning's Mills
Ontario, LON 1JO
Canada
A group
of
Canadian
PET
users are
developing a compiler for the
PET
that
will also be usable on the APPLE or any
6502 based computer. This may be a very
significant
step in regards
to
the
usefulness
of
the
PET.
This article answers the questions
indicated in its sub-headings. So as not
to
waste your, the reader's, time, you
should
just
go to those sub-headings
to
which you do not know the answer.
The Topics Being Covered are:
I.
What is a compiler?
2.
What is the difference between a com-
piler and an interpreter?
3. What is the difference between a
direct compiler and a p-code compiler?
4.
Why would a BASIC compiler be so
useful
on
a
PET?
5.
What is the status
of
the CAN
PET
BASIC compiler?
What
is
a Compiler?
A compiler is a computer program
which takes a set
of
instructions, written
according to some set of rules, and
transforms it
into
a machine language
computer program, a string
of
binary
characters. This is the
real
machine
language. Everything actually stored in
the machine can
be
represented by a
combination
of
1 and 0 digits.
January, 1980
Early computers built in the
1950's
were programmed with strings
of
binary
numbers and it was extremely
difficult
to tell where an error had been made in a
long binary string
as,
10111010110101.
There are convenient methods
of
conver-
ting binary numbers
to
other number
bases such as octal, hexadecimal, or
decimal. Thus programmers were able
to
use more recognizable numeric strings
such as,
73
(Octal)
or
A2
(Hex) to repre-
sent their Instruction Code, Operations
performed by a computer (such as add,
subtract, or move data from one location
to
another) have specific operation
codes assigned
to
them. Some com-
puters have as many as four hundred dif-
ferent operations (op-codes) in their in-
struction set.
Because
it
was still easy for a pro-
grammer
to
become confused about
what the numbers represent, a still more
simplified method of representing pro-
grams was developed using what are
called mnemonics (nuhh-monics). For
example, the letters
AD
might
be
used
for add,
SB
for subtract, and
LOA
for
load register
A.
This method
of
writing
programs is sometimes mistakenly call-
ed
machine language programming; in
fact, together with symbolic addressing,
it is Assembler Language Programming.
A program has to
be
available
that
will recognize the mnemonics
of
the
assembly
language
instructions,
translate them into the appropriate op-
codes, and allocate actual storage loca-
tions for those
..r.epresented by the pro-
MICRO
--
The
6502
Journal
grammer as symoolic names, Such a
program is called
an assembler.
If
such
a program (an assembler) is not
available and the operating instructions
are written using only numeric code, the
program is said to have been
"hand
assembled",
More powerful assemblers keep
track
of
address locations in programs
and may provide various helpful debugg-
ing aids. However,
even
the most power-
ful
assemblers
still
require
an
understanding
of
assembly language in
order to use them; and more importantly
still, the more powerful they are the
more likely they are to
be
untranspor-
table. That is to say they are unlikely to
be
able to move from one model of a
machine to another because they usual-
ly
gain
their
"macropower"
from
features
inherent
in
a
particular
machine,
Because a great deal of skill and ef-
fort is required to write a program in
assembly language, new languages call-
ed
higher level languages were designed
to make life easier. The first Widely used
such higher level language was
FOR-
TRAN (FOR-mula TRAN-slater) used
mainly by the mathematically oriented.
The FORTRAN compiler allowed the pro-
grammer
to
express his problem in
rather
conventional
looking
mathematical notation and then took
the program
SEE
BOX
and converted it
into assembly language instructions or
directly into Machine Code.
20:9