Classic Computer Magazine Archive CREATIVE COMPUTING VOL. 9, NO. 1 / JANUARY 1983 / PAGE 46

Ada for CP-M: a comparative review. (evaluation) Geoff Gilpin.

Ada for CP/M

You have to feel some compassion for anyone who would try to implement the Ada language on an 8-bit microcomputer. Face it, Ada is huge! Stuffing all of Ada's features into a Z80 processor would be like trying to pour Lake Michigan into a bathtub.

Yet reasonably complete versions of PL/1 and Cobol, languages which are much more at home on big mainframes, have found their way into the 8-bit world. But could the power and complexity of Ada be crammed into my little desktop friend? I was (and am) skeptical.

Tentative answers to the Ada-for-CP/M question have been provided by Supersoft Inc. of Champaign, IL and RR Software of Madison, WI; the other implementations that I have seen advertised run on the heftier 16-hit machines.

Supersoft Ada

Being a cautious pioneer, Supersoft is quick to point out that theirs is "presently an incomplete implementation of the Ada programming language.' But they promise that their compiler "will be further developed to enable implementation of the complete Ada language.' When ? "By the time that Ada has been recognized by the microcomputer community as a viable language for software development.' Okay.

Supersoft Ada is supplied on disk and is available in most CP/M formats. The disk contains ADA.COM, the Ada compiler; CODE 8080, a program which takes Ada pseudo-code and generates a COM file; and Kapse, the Kernal Ada Program Support Environment, a collection of I/O and other useful run-time routines that loosely conform to specifications for the STANDARD and INPUT OUTPUT packages provided by the Department of Defense.

In addition to the three system files, Supersoft provides several sample programs including two games, Startrek and Mazewars. As an Apple II owner running Ada on the Microsoft Z80 Softcard, I should mention that some of the demo programs require an 80-column screen and would have to be re-written for the Apple. Even though I use a Videx 80-column board, some of the programs used cursor-positioning commands that did funny things on my screen. Be warned.

Two documents are supplied with the disk--Supersoft's Ada manual and the DoD's own Military Standard reference, bound in khaki and written in an appropriately faceless militarese. In contrast to the DoD manual, which is thick and exhaustive, the Supersoft document is quite terse--a mere 29 pages. Mostly, it describes the differences between standard Ada and Supersoft's version. The longest section lists the parts of the language that Supersoft has left unimplemented.

The Compiler

Operation of the compiler is straight-forward. Once an Ada source program has been created with ED or another CP/M text editor it is compiled by typing "Ada' followed by the filename. If you have included the PRINT or LIST pragma in the source text (pragma is the Ada term for a compiler directive) you will get a program listing on either the screen or printer, as requested.

Syntax errors are noted by an arrow pointing to the spot where the compiler found a problem. In my experience, Supersoft's error messages aren't always to the point. For example, as the compiler was parsing a program containing the following statements:

array(0) :='X'

while array(0) /= 'Q' loop

an error was indicated at the loop statement, and a message saying "assignment operator expected' was printed when the problem was obviously a missing semicolon on the previous line.

My long association with Pascal has convinced me that a compiler should at least be able to catch missing semicolons. Other misleading error messages are produced when the user tries to redefine Ada's reserved words--another thing a compiler should be able to sniff out.

There are a couple of other minor quirks. Although the advertising promises "printer output,' the documentation doesn't mention how it's done, and so far none of the several methods that I have tried has sent a single character to my Qume. Also, the "list' pragma (for sending program listings to the CP/M LST device) doesn't work (I have tried it on two different systems).

Many Omissions

I recognize that these are the kind of small flaws that could be found in the first release of any major software package. I do have one serious complaint, however, which will appear after a more thorough tour of Supersoft Ada.

There are more data types and structures in Ada than in any other language that I have seen. There are seven predefined numeric types; scads of data structures including such exotica as array slices and variant records; and an infinite number of custom-built types and structures.

From this potpourri, Supersoft has implemented just six data types and a single data structure: arrays. No records. No user-defined types. Just the usual integers, Booleans, and characters.

A similar situation exists in one of Ada's most crucial areas: program organization. Modularity is the hallmark of Ada, and it is supported through features such as subprograms, separate compilation, packages (collections of Ada resources something like "units' in UCSD Pascal), and program libraries. The intent is to divvy up Ada programs and data in little boxes which can be accessed only through the correct protocol. This should encourage portability and make it easier to build large systems from small standardized building blocks.

How does this philosophy of divide and conquer fare in Supersoft Ada? Consider this:

Ada subprograms (specifically procedures, although functions are also supported) can accept three types of parameters --in, out, and in out. The last are used in subprograms which accept a value, modify it, and return it to the calling environment. Incredibly, Supersoft Ada supports only in parameters. That's right--any variable which is to be modified by a subprogram must be declared globally, just as in Basic. And this is the most sophisticated kind of program structure available in the Supersoft compiler. So much for modularity.

There are other strange omissions--like the lack of an exit statement to terminate a basic Ada loop--that would make serious programming very difficult.

In fact, only one of the unique features of Ada seems to have been implemented --subprogram overloading (the creation of two or more subprograms that share the same name).

After all that, I believe that the nature of my "serious complaint' should be pretty obvious. It is, ahem, this: They only implemented a tenth of the language!

To be fair, I realize that the Ada language itself is still in a period of transition. Some of the 16-bit versions haven't yet implemented the more esoteric features. Even the DoD's language definition hasn't quite solidified yet.

But does this justify a price of $250 for what is essentially a "mini-Pascal'?

Supersoft is apparently sticking to its intention of providing the full language. But they have many man hours ahead of them, and if the cost of the updates (which would comprise about 90% of the language) is proportional to the first release, I don't know anybody who will be able to afford them.

Janus

Fortunately, there is an alternative --Janus, the Ada compiler offered by RR Software. RR doesn't call their product "Ada' because they have no intention of bringing it up to the full DoD standard. That's good.

The large-scale, exotic features of Ada--such as inter-disk communication and generic program units--create so much overhead in an 8-bit machine that their implementation is, in my opinion, just plain unrealistic. RR has wisely avoided such esoterica and produced a subset of Ada that is both useful and workable.

Even with this economical approach, Janus is no lightweight. Consider:

two
describingdevoted
which
subtypes,thecomparison.likenothing

The thoroughness and careful attention to detail that went into Janus are evident from the first compilation. The user is presented with an array of compiler options that do everything from suppressing debugging code to informing about differences between Janus and standard Ada. During the four passes of the Janus compiler, information is provided on available memory, code and data addresses, table size, and anything else that might save debugging time. In fact, Janus gives you more information than the IBM Optimizing Compiler for PL/1.

Error Handling

I was particularly impressed with the kindness displayed by Janus in error handling. Syntax errors are spotted early in the compilation process, a thoughtful feature for impatient programmers using a four-pass compiler. The much trickier run-time errors generate a useful "walkback' that greatly simplifies debugging. Consider how Janus would handle the following, fatally flawed program.

package body TEST is

function FUNC (X, Y: integer)

return integer is

begin

return X/Y;

end FUNC;

procedure PROC (X, Y: integer) is

Z: integer;

begin

Z := FUNC (X, Y);

end PROC;

begin--TEST

PROC (O, O);

end TEST;

The run-time error occurs in the fifth line (counting blanks) of the program where X is divided by zero. Most compilers would just give a message such as "Divide by zero at line 5' and leave it to the programmer to track the problem down. Janus gives you this:

*** Divide by zero detected

On line number 5 in TEST.FUNC

Called from line number 12 in TEST.PROC

Called from line number 16 in TEST

I imagine that this would be a godsend for people working on a big, convoluted program.

The Janus language itself represents a hefty subset of Ada--perhaps as much as 60% of the DoD specs with more to come in updates. Janus really looks like Ada; not like a warmed-over Pascal.

All the Ada operators are here (including relational operators for arrays, records, and enumeration values), along with most of the data types including derived (new) types, the access (pointer) type, and the non-Ada byte type. (The task and limited private types, for multi-programming and data hiding respectively, will remain unimplemented.)

Good News For Systems Programmers

There are several extensions to Ada that make Janus particularly attractive to the systems programmer. (This isn't surprising --RR uses Janus for all their inhouse programming.)

There is an ASM statement that allows insertion of in-line assembly code or other binary data. For instance, the following Janus procedure will re-boot CP/M.

procedure RE-BOOT is

JMP: constant := 16#C3#;

--8080 branch opcode

--expressed in Ada

--"based number'

--notation.

ENTRY: constant := 16#0000#;

--CP/M entry point.

begin

Asm JMP, ENTRY;

end RE-BOOT;

There is also a "conditional compilation' feature that causes certain portions of code (specifically, those statements preceded by an @ marker) to be ignored by the compiler unless the user says otherwise in the command line, or toggles the CONDCOMP pragma within the source program. This feature has already saved me some debugging time and, again, I imagine that it would be invaluable in the development of a large system.

Business programmers will be pleased to know that strings in Janus are handled differently than in standard Ada. To the great relief of all, Janus strings have a dynamic length attribute. In other words, the statements

S: string(1..10) := "rendezvous';

. . .

S := "Fred';

put (S);

will print "Fred' instead of "Fredezvous.' Thank you, RR.

In addition to the language itself, several program libraries are included on the distribution disk(s). (The whole Janus package takes up four Apple disks or one single-density 8' disk.) There is a library of string-handling routines (STRING.LIB) to help with the everyday tasks of searching, replacing, and extracting strings from other strings.

A HEAP.LIB provides several low level functions such as garbage collection (reclaiming unused memory), individual bit testing and setting, and a MEMAVAIL procedure to keep you informed of how much space is left.

The third library, IO.LIB, is RR Software's solution to the somewhat controversial problem of Ada input/output. As defined by the DoD, I/O functions arent' really a part of the language itself; instead, a group of generic I/O routines are instantiated by each programmer whenever they are needed (somewhat like using a single stencil for drawing multiple copies of a design).

As far as I know, however, none of the current versions of Ada (even the 16-bit implementations) offer generics. To complicate the problem, the DoD recently redefined the procedures for handling random-access files. It seems that we can expect a year or two of daffy anarchy before the dust settles in this area of Ada.

IO.LIB contains the Janus routines for creating, reading, writing, deleting, and otherwise manipulating disk files. Other peripheral devices--the CP/M CON: and LST: devices, for instance--are also recognized. The procedures in IO.LIB, although not "standard,' look enough like those in the Ada Reference Manual to be fairly portable. The current version of Janus (release 1.4.3) does not support random access I/O, although the people at RR assure me that that is one of their priorities.

One beautiful thing about text I/O in Janus is that get and put have been extended to work with Booleans and enumeration values. (Since this feature depends on instantiation of generic packages in standard Ada we won't be seeing it in other versions of the language for some time.) To illustrate, the statements

type PHILOSOPHY is (ROMANTICISM,

IDEALISM,

NARROW MINDEDNESS);

BELIEF-SYSTEM: PHILOSOPHY;

TRUTHFUL: Boolean := true;

. . .

BELIEF-SYSTEM := NARROW-MINDEDNESS;

put (BELIEF-SYSTEM);

put (" is ');

put (not TRUTHFUL);

would print

NARROW-MINDEDNESS is FALSE

This is a really good feature (sadly missing in Pascal) which I intend to use frequently.

Omissions

There are a couple of omissions in Janus. Real numbers and multidimensional arrays are not supported as of this writing, although both should be available by the time you read this. The only important feature of Ada found in the Supersoft compiler and not in Janus is overloading of procedures and functions. The people at RR inform me that overloading is being contemplated for a future release.

So, for now at least, the jury is in--Janus encompasses at least five times as much of Ada as Supersoft, including many of the more exotic features of the language. Janus is a really useful tool, especially for systems programmers and people who wish to get a head start on learning Ada (you will learn little about Ada from the Supersoft product).

The Janus package provides nearly four times as much software (including the compiler, an 8080 assembler, a disassembler, the support libraries, and fully-documented run-time source code) as Supersoft for about $50 more.

I will leave to you the decision of which product to buy.

Products: Supersoft Ada (computer program)
RR Software Janus (computer program)