CBASIC 2.8 = CBASIC-86 1.00

Differences between the 8080 and 8086 implementations of CBASIC
by Emmanuel ROCHE

CBASIC is the oldest BASIC running under CP/M. You may remember
that Gary Kildall was a Computer Science professor at the Naval
Postgraduate School of Monterey, California, teaching compiler
writing by using his own ALGOL-like compiler as an example. To
write this demo compiler, he needed a "system language", so he
created PL/M, that he wrote in FORTRAN-66 (so as to be portable)
on an IBM System/360 (the "standard" hardware, back then)
running under CP/MVS.

PL/M had been designed to "replace serious system programming in
assembly language" for the brand-new Intel 8008 CPU (and the
8080, which appeared just a few months later). To use this PL/M
compiler on the first Intel demo microcomputers, Gary needed one
Operating System. After seeing the first 8-inch floppy disk
drives (used by IBM to replace paper tapes), he decided to write
one DOS for floppies, that he called CP/M, rather than for
magnetic cassette tapes, as several other persons did in the
early days of microcomputers (copying what they were using at
work on mini-computers).

Several students of Gary wrote compilers for their Master of
Science Theses, using PL/M. One of them was Gordon Eubanks, Jr,
who choose to make an "Extended BASIC" following closely the
first BASIC, Dartmouth BASIC. It was named NBASIC, standing for
NPS BASIC. It was running on the S/360 of the NPS, under an
emulator emulating CP/M 1.2. Gordon wrote it with two other
students, in six months. It is heavily based on the ALGOL
compiler of Gary Kildall.

BASIC had made a revolution as a simpler way to use computers.
So, Gary logically choose it as one of the first programs to be
released for CP/M. Gary ported NBASIC under CP/M 1.3, renaming
it BASIC-E (E standing, of course, for Eubanks) in the process.
The source code of this version can be found in the first
"Volumes" of the CP/M User's Group 8-inch disks.

BASIC-E was very popular, because it enabled people to write
useful software for CP/M with very high numerical precision, yet
managed to run in a 24K TPA. Even better: since it was a
compiler producing INT files, the source code was not released!
"Commercial" software "houses" (well... kitchen tables, in most
cases) loved this feature.

BASIC-E was so successful that an S-100 Bus card executing
directly the INT files produced by BASIC-E appeared, greatly
increasing their speed (10 times faster than interpreting them).

After Digital Research was created, it was found that it needed
a BASIC to sell... So, a third version was made, named this time
CBASIC. Maybe it is because Gary Kildall was teaching compiler
writing, but an interpreted version never appeared, and CBASIC
remained a compiler.

Over the years, CBASIC evolved very, very little. The highest
known version number is 2.8. Since CP/M-86 (Plus) is
experiencing a revival, I though that the 8086 version of
CBASIC, known as CBASIC-86, would be interesting.
Unfortunately, it was nowhere to be found, so I called several
times for it on the comp.os.cpm Newsgroup over the years (and
tracked the sender of every message that I managed to found
dealing with it for the NEC APC -- to no avail).

Very recently, someone warned me that a lost copy had finally
been found. However, as usual, no paper doc seems to have
survived. So, we are going first to investigate how different
the 8080 and 8086 versions of CBASIC are. Since they are
compilers, we also first need a simple demo program. It is a
tradition to start with a program displaying "Hello, World!" on
the screen, so let us follow the custom.

The first thing to note is that this CP/M-86 version of
CBASIC-86 is titled "CBASIC/86"... One small patch will quickly
remedy this "MeSs"...

The second thing we note is that the version numbers differ: the
8080 version is 2.8, the 8086 version is 1.0. So, we need to
investigate a little deeper how different/identical they are. To
do this, short of a complete disassembly of the compiler, the
simplest and easiest way is to have a look to the ASCII strings
stored in both versions. DUMPASC to the rescue!

But, before, let us try a simpler test: see if the 8080 and 8086
versions of CBASIC can run **THE SAME** INT file?

First thing to note: The copyright dates are 1977-1981 for
Compiler Systems, Inc, and 1981-1983 for Digital Research, Inc,
for Version 2.8. And we just saw that the CP/M-86 version was
dated 1981, and copyrighted by Compiler Systems, not Digital
Research...

Hugh? At the beginning, it says that it is Version 2.8, and
inside it says that it is Version 2.08... (Personally, I have a
book using Version 2.07, so this was probably the version number
used by Compiler Systems. Digital Research probably shortened it
to 2.8.)

Always this date of 1981, and I did not see any MP/M-86 code or
message dealing with the printer...

One funny difference: the compilers are "copyright date", while
the run-time systems are "copyright (c) date"!

I also noticed another funny bug in the XREF utility for CBASIC:

XREF04: TO MANY FUNCTIONS
XREF05: INCLUDE NESTING TO DEEP NEAR LINE

Maybe someone could warn Compiler Systems that "to" should be
"too", in both cases? (This bug is present in both versions, so
I am ready to bet that it is a PL/M program recompiled without
having a look at it...)

What to do?
-----------

As can be seen, both compilers contain a list of keywords at
their beginning. But how to compare them? I decided to do it as
simple as possible: cut those lists with an editor, then put
each keyword on a separate line. Most keywords are separated by
a ".", but some have funny characters. While doing this, it
became clear that those keywords are listed according to their
number of characters, so I added a few paragraph titles, then
saved those "CBASIC(-86) Keywords" files.

I now had 2 ASCII files. Using the editor, I could see that they
had the same number of lines... But how to be *ABSOLUTELY* sure
that both files are identical? Of course, I could simply run my
COMPARE.BAS program, but the titles of the files and one comment
line was different in both files...

I remembered my DUMPATWO utility, which dumps 2 files in ASCII
side by side. Clearly, one way to check both files would be to
display them side by side... After a quick hack, I got the
following:

We have demonstrated that the 8080 and 8086 versions of CBASIC
have the same keywords. So, CBASIC Version 2.8 = CBASIC-86
Version 1.0.

The only difference I can see at a glance, without disassembly,
is that the 8080 version can also run under MP/M, while the 8086
version seems only to run under CP/M-86. And the 8086 version no
longer checks the printer.

However, if anybody out there finds a copy of the CBASIC-86
User's Guide for CP/M-86, I will be very happy to know what it
says. In particular, I would like to know how to CALL 8086
subroutines...

If you ever wrote any, say, "General Ledger" for CP/M 2.2, you
will be happy to learn that you can continue to use it under
CP/M-86! Of course, your 8080 assembly language subroutines will
no longer work, but it look likes CBASIC-86 can run natively
8080 INT files... This Old Faithful "General Ledger" is going to
run!