image of READY prompt

Wang2200.org

Background (link)

The first generation Wang 2200 CPU ran the dialect of BASIC known as "Wang BASIC." The CPU went through a few revisions of a relatively minor nature: repackaging as technology advanced, adding more microcode to support additional features. None of those changes affected performance.

While the Wang BASIC was advancing, the design team started a new CPU project from scratch in 1974(?). While the influence of the first microarchitecture is evident in the second, the changes were large and required a complete rewrite of the BASIC interpreter. This new BASIC dialect was called BASIC-2.

Although backward compatibility was a major goal, the designers of BASIC-2 took the opportunity to extend the syntax and power of the language.

This page doesn't try to cover every detail of BASIC-2; it tries to highlight some of the interesting and significant improvements made to the BASIC dialect. It will make the most sense to those who only know Wang BASIC. Those who know BASIC-2 will probably be amazed that Wang BASIC programmers lived without some of these features.

Still the Same (link)

BASIC-2 was nearly a strict superset of Wang BASIC; only a handful of language features were dropped, and the vast majority of Wang BASIC programs ran under BASIC-2 unchanged or with only a minor edit.

Fundamental features of Wang BASIC that didn't change for BASIC-2 included:

Better Performance (link)

BASIC-2 running on the VP CPU was also dramatically faster, typically about eight times faster. Some of it was due to the shorter microinstruction cycle time, some due to the more powerful instruction set, and the rest due to a shift in priorities to write the interpreter to be fast instead of small.

More Robust Implementation (link)

As noted on the Stupid Tricks page, Wang BASIC had a number of design flaws.

BASIC-2 was much more robust, for a few reasons. One reason was that the VP CPU used static RAM for holding microcode instead of ROMs. This meant that as bugs were discovered, they would be routinely fixed in the next release of the operating system, which entailed mailing out floppy disks, instead of having to upgrade as many as 20 ROMs.

Another reason was simply that the designers of BASIC-2 thought very hard about making it difficult for an end-user to peek into the innards of the implementation. For instance, in Wang BASIC, when a line was recalled for editing, the user was editing the tokenized representation of the line. This allowed injecting bogus token values into the edit buffer. In contrast, BASIC-2 detokenized the line before editing, then retokenized after editing.

As another example of the more robust design, more care was taken to preserve accuracy in implementing the fundamental computations, namely add, subtract, multiply, divide, transcendentals, and even RND(). Not only was RND() almost 100 times faster in BASIC-2, it was more random!

Raising the Existing Limits (link)

The simplest kind of improvement that BASIC-2 made was to improve a few of the limits that were part of Wang BASIC operation.

Generalization of Existing Features (link)

In a number of commands and functions, BASIC-2 took an existing Wang BASIC feature and added to the syntax to allow for more functionality. Some of these features were common in other BASIC dialects, but many were unique to BASIC-2. Below are some examples.

New Functions (link)

BASIC-2 added some new functions, as briefly described here.

FIX(v)
Integer part of the expression
Same as SGN(v)*INT(ABS(v))
MOD(v1,v2)
Finds the remainder of v1/v2
ROUND(v1,v2)
Rounds v1 to the v2'th decimal place; v2 can be positive or negative
MAX(v1[,v2...])
Finds the maximum value among the specified expressions or numeric array(s)
MIN(v1[,v2...])
Finds the minimum value among the specified expressions or numeric array(s)
LGT(v)
Finds log base 10 of the expression
VER(A$,F$)
verifies that a string matches a given format

Clarifying a bit, MAX() and MIN() took a variable number of arguments, including array references. For example, 100 M = MAX(0, A()) finds the largest number in the array A(), but if that number is negative, zero is returned instead.

New Commands (link)

BASIC-2 added some entirely new commands to the language, in addition to the improvements already noted to existing commands. Many other commands were added to BASIC-2 once the MVP OS was developed, but won't be listed here.

Multiuser Operation (link)

The initial releases of BASIC-2 were for the 2200 VP CPU. The VP OS supported a single user, just like the first generation machines. With the introduction of the 2200 MVP CPU, the OS was reworked to perform time sharing between multiple "partitions." Once a partition was selected to run, it would occupy the CPU until either it blocked waiting for some I/O device, or a 30 millisecond timer expired. It would then be put back on the task list, and the next task would be started, in round-robin order.

A partition was a contiguous chunk of memory which held a BASIC context: a program and its associated data. Although the simplest scenario maps each terminal to one partition, it was possible for a single terminal to control multiple partitions, with one in the foreground and one or more in the background. Background partitions would timeslice along with all the other partitions until they blocked trying to access the terminal I/O device. At the point the blocked partition was moved to the foreground status, it would spring back to life.

The details of defining and managing partitions were complicated, such as the minimum and maximum size of a partition, how the partitions mapped into 64 KB "banks" of memory, and how partitions were mapped to terminals. Further complicating things, an 8 KB section of RAM, a "global partition", could be made accessible to other partitions, again with various restrictions. This global code and data could shared between cooperating partitions.

Many commands were introduced into BASIC-2 to manage partitions and resource sharing. Some existing commands that did not play well with resource sharing and time slicing either were modified or had constraints placed on their use. Some commands to manage concurrency and resource sharing.

To get the full story, see Chapter 16 of the BASIC-2 manual.

Differences Between Versions (link)

For the most part, BASIC-2 retained just about all the syntax and functionality of Wang BASIC. See Appendix C of the BASIC-2 manual for a detailed exposition. Here, then, are just a few key differences.