One of the software products Hewlett-Packard produced for the early 2116 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 process to produce an executable of the BASIC interpreter to run on a 21xx-series processor, starting from this original HP source.
|Contents (this page):||Resources:||
Sources & References:
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 case of reading, the BASIC interpreter needs time after an EOL (carriage return) to process an input line - even low bit rates (150 or even lower) and two stop bits is insufficient. 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.
In a modern context a console teletype with reader and punch may be simulated with an async-line serial communication program (SCOMM is such a program, prepared for both text-based console operation and binary-transparent transfer of files). The interpreter seems to send the 8th bit always 1 so the receiving host needs to ignore it. The flow control requirement for 'paper-tape' reading can present a difficulty. 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 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 actual flow-control. Alternatively, the PBS reader-driver routines might be hacked to keep a read pending and do some character queuing.
User commands are limited to:
Input-line editing is also limited:
The workflow is shown in the diagram below. Assembling the source (steps 1, 2, 3) may be avoided if one uses the .abs load files contained in the download archive linked above.
If HP BASIC is loaded at step 5b, before PBS is run, PBS will produce an absolute tape with both the configured I/O package and the BASIC interpreter, thus a single boot tape. Otherwise, the output from PBS will contain only the configured I/O package and loading the complete BASIC system is two steps: loading the I/O package (step 7a) and loading the interpreter (step 7b). In either case, HP BASIC must be loaded after it's compatriot as it intentionally overwrites some memory locations.
Also, if HP BASIC 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 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.
Once the complete BASIC system is loaded into the processor, the non-volatility of core should work to advantage when re-booting BASIC. At power-up, assuming the data switches are left at the BASIC start address of 0100, booting is just 3 button pushes on a 2116: PRESET, LOAD-ADDR, RUN.
Memory Map & Notable Addresses
Contents or Use
|000002||JMP 3,I||PBS start jmp|
|000004||HLT 4,C (power fail)||link area begin|
|000005||HLT 5 (parity fault)||..|
|.. 0 ..||..|
|63||000077||HLT 077||..||BASIC begin|
|000101||PREAD||addr of .HSPR [P]||..||..|
|000102||WRITE||addr of TTY.P [P]||..||..|
|000103||PUNCH||addr of .PUNCH [P]||..||..|
|000104||REED||addr of TTY.I [P]||..||..|
|000105||addr of stop routine [S]||..||..|
|000106||LWBM||LWAM for BOSS [B1]||..||..|
|000107||BOSS linkage [B2]||..||..|
|000110||FWAM||ptr to first avail. word||..||..|
|000111||LWAM||ptr to last avail. word||..||..|
|000123||IMOFF||kbd intr disb [P]||..||..|
|000124||IMON||kbd intr enb [P]||..||..|
|000125||TLINK||tty intr [P]||..||..|
|000130||TLSTR||list output addr||..||..|
|000134||SBUFA||*||link area end||..|
|000135||SBPTR||*||..||<-- FWAM (I/O Pkg)|
|000201||START||ptr to ENTRY||..|
|002010||ENTRY||BASIC start entry||..||<-- jmp from 100|
|013142||user/runtime begin||<-- FWAM (BASIC)|
|015073||*||I/O 'serial' begin||..|
|015677||*||I/O 'serial' end||..|
|016333||PBS start entry||PBS begin||..||<-- jmp from 2,3|
|017346||LWAMP||user/runtime end||<-- LWAM|
|7911||017347||.PNCH||PT punch routine||I/O 'bufferred' begin||I/O drivers begin|
|017370||.HSPR||HS PT read routine||..||..|
|017426||TTY.I||TTY read routine||..||..|
|017445||TTY.P||TTY print/punch routine||..||..|
|8127||017677||*||I/O 'bufferred' end||I/O drivers end||<-- LWM|
|8128||017700||BBL start entry||BBL begin||BBL begin|
|017777||*||BBL end||BBL end|
Two template I/O packages are included and initially loaded with PBS, one for the 'serial' and one for the 'bufferred' teletype options. Only one of these will be included in the configured system. When BASIC is running, the I/O package will reside near the top of memory, just below the Basic Binary Loader. The bufferred routines are initially loaded right where they should be for an 8KW system (as shown). If more core is available, PBS will specify them to be reloaded appropriately higher in memory. The serial (bit-banged) routines will similarly be relocated as necessary, in an 8KW system they will be relocated to where the bufferred routines are shown.
The BASIC interpreter resides near the beginning of memory. When BASIC is running, memory between the end of the interpreter and the beginning of the I/O package - identified respectively as FWAM / First Word of Available Memory and LWAM / Last Word of Available Memory - is available for the user BASIC program and runtime needs. PBS configures LWAM to one of several locations depending on which I/O devices were specified as available.
When PBS is loaded, FWAM points to a low address, just enough to include the I/O linkage for subsequent use by BASIC. If the interpreter is to be included in the absolute tape punched by PBS, PBS must be loaded before the interpreter. Loading the interpreter will overwrite FWAM with a higher value so it will be included in the punch.
(Note the table areas are not proportionate relative to actual address range.)
[P] These are the links for the interpreter to invoke routines in the I/O package. They are prepared by PBS and loaded as part of the I/O package.
[S] This is a link for I/O routines to callback to a stop routine in the interpreter. It is prepared by the interpreter.
[B1] The sources make several references to BOSS. BOSS seems to be some sort of executive. BOSS involvement seems to be limited to starting and quitting BASIC. The I/O Package sets LWBM to the same as LWAM. BOSS may adjust LWBM. When the interpreter runs it sets LWAM to the same as LWBM if they differ.
[B2] Not explained.
CTµL | 2116 | I/O Interfaces | Programming Ref | Software | 2116C Refurb
HP 21xx Series