BASIC PROGRAMMING EXAMPLE
For one of the best articles on the history of BASIC, see >>here<<
After powering up the IBM 5110, the bottom right corner of the screen shows the 28K available RAM (32K total, so nearly 4K used by the system services itself — consistent with the IBM manual that states “4300 bytes internal requirement” in its memory map), followed by what column the cursor is currently on (within the 64×16 text screen). The sample shown below is a simple BASIC program that uses much of the same syntax as more modern BASIC programs.
10 PRINT 'NAME: '; (use SHIFT-K for single quote ') 20 INPUT A$ ($ used to store "string" variables) 30 N=5 40 FOR I=1 TO N 50 PRINT A$; (the ";" keeps cursor on same row) 60 PRINT ' '; 70 PRINT I*3.14159 (3.14159 is a value of PI, no ";" here) 80 NEXT I 90 PRINT 'DONE.' RUN
Given its age and rarity, I try not to power on the system too much. There is an excellent online 5110 emulator, to practice some code before exercising it on the physical system. Without a tape, I do have to key in a program each time the system is powered on.
The IBM 5100 system was focused on science and engineering applications, so it supports floating point, matrix operations, and full suite of trig (sin, cos, tan) and common math operations (e.g. log, secant, square root). The IBM 5110 retained all this same capability, but was enhanced to also cater to more general purpose “data processing” application. Specifically, the 5110 BASIC now had the “FORM.”
Each data entry form consists of fields that have specific entry requirements, like the format of SSN, phone numbers, zip codes, or constraints on general numerical inputs. The BASIC used in the 5110 has syntax that helps define these forms and move the cursor between fields, and then the data that is entered can be stored into files. Much of the programming was defining where form input fields would be located, what data is requested, and storing that data to cassette (or disk). As with the concept of “stdout,” the 5110 BASIC did treat the screen as a file device, accessed as index ‘002‘. As these data records accumulated, the job was then to search, sort, and print information about these records (such as billing invoices), and produce reports (such as clients that are past due). Each such program quickly became proprietary in the arrangement of data records, so specialist were required to maintain these programs. This was decades before SQL, XML, JSON (which only evolved due to enormous leaps in hardware performance capability).
The sample program below (from the IBM BASIC manual) requires careful decision of which screen POSSITION OFFSET to use. Per the specified programming, the input fields are limited to 18 characters (anything past that is cropped). No code is necessary to manage moving the cursor to the next field, this is handled by how the FORM is defined within the BASIC code itself (where the FORM command is executed by the BASIC ROS/ROM code).
The BASIC of the 5110 had no provisions for things like clearing the screen, polling keyboard single key presses, or writing to arbitrary locations of the screen. Keep in mind the 5110 BASIC is said to have been based of the BASIC used for the System/3 (see here), which was a system that had none of these capabilities. The idea of an interactive screen terminal was still new, even by the mid-1970s. The “output” of most programs was still via a line printer, so the idea of “clearing the screen” and “writing to x,y” wasn’t matured yet. And in a Data Processing machine, the need wasn’t apparent. The goal was to “process data”: store records, generate reports, and print those reports to hand over to management or clients (i.e. other people who didn’t have a computer).
From this perspective, the 5110 BASIC is quite suitable. But for creating more interesting and “fun” games, the options are quite limited. Simple text adventures or “guess my number” type games are possible, but not much in terms of interactive adventures or even “pong.”
However, BASIC (or APL) is not the only way to program this machine. The core PALM processor itself is available. The core functions available in the Executive ROS or Common Language ROS remain somewhat obscure (undocumented), but the PALM itself does have a set of registers and opcodes.
Using the built-in diagnostic assembler, we can encode instructions in pure machine language. From this, conceptually one could define their own BASIC or Pascal or C compiler. But a better approach is to prepare the PALM instructions on another (modern) machine, then find a way to load that binary sequence onto the 5110. The next section demonstrates this.