HP 21xx
Series
Single-User
HP BASIC
 

One of the software products Hewlett-Packard produced for the early 211x series machines was a single-user BASIC interpreter. Around 2010 a version of the assembly source, dating from 1970, for the interpreter and associated configuration program became available on bitsavers. This was thanks to Guy Sotomayor who had kept it around since high school in 1971.

This article descibes the requirements and process to get the HPBASIC interpreter to run on a 211x-series processor, starting if necessary from the original HP assembler source.

Historical Note

BASIC was originally (1964) developed on and targetted for multi-user time-shared systems. The early home computer market of the late-1970s to 1980s would largely be characterised by boot-to-BASIC machines: small machines with a BASIC interpreter in ROM which at power-on would immediately boot that interpreter and present BASIC ready to use, machines such as the Apple II, Commodore PET, TRS-80, etc.

Between the large time-shared systems and the small boot-to-BASIC machine, a few waypoint developments can be identified. The earliest (known to this author) instance of a ROM-based BASIC machine is the HP-9830 (1972), followed by the Wang 2200 (1973) and IBM 5100 (1975). Single-user HP BASIC is an even earlier waypoint.

The available assembler source for Single-user HP BASIC is dated January 1970. An HP computer products brochure from June 1968 lists an "interpretative compiler" for BASIC, "operable in 8K" - this being distinct from the HP2000 Timeshared BASIC system for the 2116, also available by 1968.

Single-user HP BASIC could be used as a stand-alone system - it did not require the presence of an OS or executive, nor did it have to sequentially overlay or reload segments of the system to accomplish functionality. Once an HP BASIC system was in core, it was a stand-alone system requiring only the computer and teletype/console for entry and execution of BASIC programs. Combining this stand-alone ability with the non-volatility of core memory, it is possible to have the BASIC "READY" prompt in 2 seconds (3 button-pushes) from power-on of the computer. An HP-2116 with HP BASIC in 1968 may have been the first "boot-to-BASIC" system, though not quite boot-to-BASIC-at-power-on.

Contents (this page): Sub-pages: Resources: External:


System Requirements

Processor

HPBASIC should run on all the early machines (2116, 2115, 2114), the 2100, and presumably the later-series machines.

8KW minimum of memory is required. For an 8KW system using the bufferred I/O option, there will be ~ 2.1KW available for the user program and runtime needs.

Console

The HPBASIC interpreter talks to the user through the console (originally a teletype), connected via either a 12531A or 12531B/C/D async serial I/O interface. The interpreter echoes characters input from the console. CR (carriage return) is the EOL character for input, and is echoed as a CRLF pair.

In a modern context a console teletype may be simulated with an async serial-line communication program running on some host machine. Such a setup will be referred to here as the console-host. The interpreter usually outputs the 8th bit set 1, so the receiving console-host needs the ability to ignore it. SCOMM is a recommendation for such a program, providing for both text-based console operation and text or binary-transparent transfer of files.

Storage

Storage for user BASIC programs is based around paper tape. The paper-tape devices may be separate 'high-speed' reader and punch devices, or the reader and punch on a console teletype.

In the modern context, loading and saving files via a console-host as simulated paper-tape reader and punch is the simple solution.


Running HP BASIC

As software, an HPBASIC System is comprised of two program elements:

The I/O Package is roughly equivalent to what would be called the BIOS in CP/M and MS-DOS a few years later. These two machine-code program elements must be in core for HPBASIC to run.

An I/O Package is produced by running the configuration program PBS (Prepare BASIC System) on the period HP machine. PBS contains template device drivers and produces an I/O Package based on input responses when it is run.

The full workflow starting from assembler source to a running HPBASIC System is shown in the following diagram:

This process can be entered from several starting points depending on the initial availability of the internally-generated resources.

If HPBASIC is loaded at step 2.2b, before PBS is run, PBS will produce an absolute tape with both the configured I/O package and the HPBASIC interpreter, thus a single boot tape. Otherwise, the output from PBS will contain only the configured I/O package and loading the complete HPBASIC System is two steps: loading the I/O package (step 3.1a) and loading the interpreter (step 3.1b). In either case, HPBASIC must be loaded after it's compatriot as it intentionally overwrites some memory locations.

Also, if HPBASIC was loaded, after running PBS it is permissible to skip step 7 and run the now-configured BASIC system directly from core. Note though, that to do so one must not allow PBS to dump (punch) the configured system. Apparently PBS corrupts the in-core system in the course of dumping it, attempting to run the in-core system after dumping will result in BASIC responding with "ERROR IN LINE " to all input.

The Memory Map presents more details about the program elements and their organisation in core.

PBS Execution

PBS obtains configuration information from both the front panel Sense switches and from queries via the console.

PBS provides a configuration option for "buffered" or "serial" TTY driver. This does not refer to a line or multi-character buffer in memory, or a serial versus parallel interface. It refers to which of the HP serial I/O interfaces is present in the processor for communication with the TTY/console:

When run, PBS performs the following sequence of activities:

  1. Select the bufferred or serial I/O driver for the TTY/console, based on Sense-switch 15.
    If switch 15 is down, buffered is selected: If switch 15 is up, serial is selected: The device channel address is now set in the selected driver, as indicated by Sense-switches 0-5. The now-configured TTY/console driver is used for both the following PBS queries and for incorporation in the I/O Package for use by the interpreter.
  2. Query: PHOTO READER I/O ADDRESS?
    This is the device used by the interpreter PTAPE command for loading user programs.
    Response: {2-digit channel number} {RET} Response: {RET}
  3. Query: PUNCH I/O ADDRESS?
    This is the device used by the interpreter for storing user programs via the PLIST command.
    Response: {2-digit channel number} {RET} Response: {RET}
  4. Query: SYSTEM DUMP I/O ADDRESS?
    This is the device to which PBS will output the configured system in absolute-load format.
    Response: {2-digit channel number} {RET} Response: {RET}
  5. Query: CORE?
    Response: {number>8} {RET} Response: {RET}
  6. Set assorted table pointers.
  7. Halt the CPU.
  8. When RUN is pressed, dump two segments of absolute-load data to the previousy specified dump device:

See PBS Execution Example.


Supported Language and Commands

See the HPBASIC User Manual.

HPBASIC is essentially adherent to the original BASIC, it does not have common alterations and extensions present in later BASICs; for example, "LET" is mandatory in assignments. Some limitations are:

There are two non-standard extensions present in HPBASIC:

User commands are limited to:

Input-line editing is also limited:



Using HPBASIC

Loading Programs

When loading a program, the interpreter needs time after an EOL (CR) to process an input line. In the original scenario, both the high-speed reader and the teletype paper-tape reader are controlled by a signal from their I/O interface to provide flow control on a per-character basis.

For the modern context of a simulated teletype or paper-tape reader, this flow control requirement can present a difficulty - even low bit rates (150 or even lower) and two stop bits is insufficient in providing enough time for line processing. Adding nulls after the EOL is not adequate due to the way the 12531B/C/D interfaces work - when the interpeter starts a read part way into transmission of a null character a bad character may be read, as the 12531 is not edge-triggered on the start bit. Explicit time delays after EOL, unless longer than may be desirable, may not work with USB-serial interfaces due to bufferring in the interface. If the console simulator supports hardware flow-control the READ-COMMAND signal from the 12531 might be adapted to RS-232 levels to provide flow-control.

The interpreter however, does provide an opportunity for character-oriented flow control. During normally typed input, the interpreter starts processing an input line after receiving the CR from the console, but does not output the echo LF until after completing that processing. SCOMM again, provides a facility to support this character stop-start control of transmission, via the sflow command. This is not a perfect soultion however, in that if there is an error in the source code, the consequent returned error message will confuse and may hang SCOMM. Note: When using this method, do not use the interpreter TAPE command, it does not echo an LF, simply let the console-host transmit to the interpreter at the 'prompt' level. [See: "Pocket Guide to HP Computers", page BASIC A-1].

Saving Programs

When using a console-host program, programs can be saved using the LIST command while redirecting the output at the console to a file. A line with "READY" will unfortunately be appended at the end of the file, this should be removed to avoid an error message on reloading.


See Restarting Example.


Some Simple Programs

A few programs compatible with HPBASIC in 8KW.


  Memory Map | Operation Examples
HP BASIC
CTµL | 2116 | I/O Interfaces | Programming Ref | Software | 2116C Refurb
HP 21xx Series
bhilpert
2014 Sep
2025 May