Est. 1986 Intermediate

IBM 4680 BASIC

IBM's compiled BASIC for the 4680 Store System, built on Digital Research's CBASIC compiler, LINK-86 and LIB-86. It was the main language for point-of-sale terminal and store controller applications on the 4680 and its successor, the 4690 Operating System

Created by IBM, based on the CBASIC Compiler, LINK-86 and LIB-86 from Digital Research

Paradigm Procedural, Imperative (compiled, structured BASIC)
Typing Static, declared (INTEGER*1, INTEGER*2, INTEGER*4, REAL, STRING), with % and $ name suffixes
First Appeared 1986
Latest Version Version 1 Release 2 of the IBM 4680 BASIC licensed program (date not established); still documented for IBM 4690 OS Version 6 in 2012

IBM 4680 BASIC is the compiled BASIC that IBM supplied for programming its 4680 Store System, the point-of-sale (POS) system it announced in January 1986. The system paired an IBM PC AT store controller with up to 64 IBM 4683 cash register terminals on a store loop. IBM did not write the compiler from scratch. Digital Research described it in March 1986 as “a powerful new implementation based on Digital Research’s CBasic Compiler, LINK-86 and LIB-86”, and IBM’s own later manuals refer to “the 4680 CBASIC” compiler and “the CBASIC language”.

4680 BASIC is easy to overlook because it never ran on a general-purpose computer. Its programs ran cash drawers, receipt printers, scanners and scales. They also outlived the 4680. IBM’s 4690 Operating System, announced in 1993 as the replacement for 4680 OS, kept the language and its name, and IBM’s documentation for 4690 OS Version 6 still listed the IBM 4680 BASIC: Language Reference in 2012.

History & Origins

The 4680 Store System

IBM had sold dedicated retail systems since the 3650 in the 1970s. The 4680 was a change of direction. The store controller was a variant of the IBM 5170 Personal Computer AT (models 839 and 899), and the 4683 terminal, like the controller, was based on the Intel 80286.

IBM announcement letter 186-003, dated 8 January 1986, introduced the 4683 terminal as “the primary terminal for the IBM 4680 Store System”. Up to sixty-four 4683 Model 1 terminals could be attached to a store controller over a 38.4 kbit/s store loop, and each Model 1 could have one secondary Model 2 terminal attached to it. Under “Software Requirements” the letter says that the IBM 4680 Operating System (5669-033) was required, and that users could buy application software such as the IBM 4680 General Sales Application (5669-031) “or write their own application program using the IBM 4680 Basic Language licensed program (5669-034)”.

Built on Digital Research software

The operating system came from Digital Research. In the March 1986 issue of its European Review, DRI reported that “in both terminal and Store Controller, the IBM 4680 Store System uses the power of Digital Research’s Concurrent DOS-286”, the multitasking operating system that DRI later renamed FlexOS. The same article describes the programming language:

In addition it permits fast development of retailer-specific applications written in IBM 4680 BASIC, a powerful new implementation based on Digital Research’s CBasic Compiler, LINK-86 and LIB-86.

CBASIC was a natural choice. Gordon Eubanks wrote it, and his company, Compiler Systems, sold the CB80 compiler until Digital Research acquired the company in 1981. CBASIC had been widely used for commercial CP/M software. Line numbers were optional, and its 14-digit binary-coded decimal arithmetic avoided the rounding errors that troubled accounting programs in other BASICs. Digital Research also sold 16-bit versions for the 8086 family, which is where the LINK-86 and LIB-86 tools named in the 1986 report come from.

The tool names stayed with the product for its whole life. IBM’s 1996 4690 Store System: Programming Guide has chapters on “Using the LIB86 Library Utility” and “Using the Linker Utility and the POSTLINK Utility”, whose command is LINK86. Its list of system files names the compiler as BASIC.286 (“BASIC compiler: front end”) and BASICCG.286 (“BASIC compiler: code generator”).

From 4680 to 4690

IBM extended the 4680 OS through several versions. Wikipedia’s FlexOS article lists 4680 OS Version 1 Releases 1-3 and Versions 2, 3 and 4. IBM’s December 1986 and December 1987 announcement letters both require Version 1 Release 3. In 1993 IBM announced the 4690 Operating System, based on FlexOS 2.32, as the successor to 4680 OS. Wikipedia gives July 1993 for the announcement, although the IBM letter it cites (293-281) is dated 1 June 1993, and says the system was generally available from 25 March 1994. The language did not change its name. In the 4690 manuals it is still “IBM 4680 BASIC”, sometimes “4680/90 CBASIC”, and it sat alongside C, COBOL and later Java as a way to write 4690 applications.

Design Philosophy

4680 BASIC was designed for a store, not a classroom. A store system has one controller and many terminals, and both run unattended programs that must not lose a sale. The language reflects this in four ways:

  • Two kinds of program. The %ENVIRON compiler directive tells the compiler whether a module will run in a terminal or in the store controller. Terminal programs are small and use different memory models from controller programs.
  • Devices are files. POS hardware is opened by name and read and written with the ordinary I/O statements, so a cash drawer is OPEN "CDRAWER:" AS 1 and the customer display is OPEN "ANDISPLAY:" AS 2.
  • Files are a first-class concern. The language can create random, direct, sequential and keyed files, and record locking is part of the CREATE and READ syntax.
  • Errors are expected. Programs set an ON ERROR GOTO handler and examine system variables such as ERR, ERRL, ERRF% and ERRN to recover from device and file errors instead of stopping.

Key Features

Compilation model

4680 BASIC is compiled, not interpreted. The 4690 Programming Guide describes a conventional toolchain:

StepToolOutput
CompileBASIC (front end) and BASICCG (code generator)One relocatable object (.OBJ) file per program module
Build librariesLIB86Library (.L86) files
LinkLINK86An executable .286 load module, with optional .MAP, line number and debug (.DBG) files
Post-processPOSTLINKFinal adjustment of the load module

Each object module has a code segment of up to 64 KB. A terminal load module can have up to 200 code segment names, of which the compiler reserves up to five, so a terminal program can be linked from at most 195 object modules. The linker supports a maximum code size of one million bytes. Large programs can be split into overlays or separate load modules joined with the CHAIN statement.

Memory models

The 1996 guide says that “IBM BASIC supports three different memory models: large (for store controllers) and big and medium (for terminals)”:

ModelWhereData limits described by IBM
MediumTerminalStack, static data and heap share one segment of no more than 64 KB minus 16 bytes, with a fixed 2 KB stack
BigTerminalUp to one 64 KB segment of static data, plus a heap that grows dynamically and up to 64 KB of stack
LargeStore controllerMultiple 64 KB segments of static data, up to 1 MB, with a dynamically sized heap

The FRE function returns the total free heap space and MFRE returns the largest contiguous free block. Strings, array elements and file buffers live in the heap.

Data types and syntax

The language has fixed-size integers (INTEGER*1, INTEGER*2 and INTEGER*4), REAL numbers and STRINGs. Variables can be declared explicitly or typed by name, with % for integers and $ for strings, as in CBASIC. Other conventions visible in IBM’s sample programs:

  • ! starts a comment, and a trailing \ continues a statement on the next line.
  • Labels such as ERR.HNDLR: are names, not line numbers, and names may contain periods.
  • Hexadecimal constants end in H, as in 000000FFH.
  • SUB ... END SUB and FUNCTION ... END FUNCTION define procedures. Adding EXTERNAL declares one that lives in another module or a system library.

Files

The 4690 Programming Guide lists four file types, all created with forms of the CREATE statement:

TypeCharacteristics
RandomFixed-length records of delimited ASCII fields ending in CR/LF, located by record number
DirectFixed-length binary records with no delimiters, written with a format string
KeyedRecords located by a key through Keyed File Services. Created with CREATE POSFILE ... KEYED, in the store controller only
SequentialVariable-length records of comma-delimited ASCII fields, read from first record to last

Formatted I/O uses WRITE FORM and READ FORM with a format string. IBM’s example creates a one-record keyed file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
STRING A, D, KEY
INTEGER B
REAL C
CREATE POSFILE "KEYFILE.DAT" KEYED 4 , , , 200 \
    RECL 19 AS 4 LOCKED
KEY = "key1"
A = "ABC"
B = 32767
C = 27.35
D = "C4, C3, I2, R"
WRITE FORM D; #4; KEY,A,B,C
CLOSE 4
END

Here KEYED 4 sets a 4-byte key, the empty positions take the default randomizing divisor and chaining threshold, 200 is the number of records, and the format string C4, C3, I2, R writes a 4-character key, a 3-character string, a 2-byte integer and a real.

Terminal programs reach controller files through the node prefix R::, usually with a logical file name such as R::EALABCDE, so the same program works whichever drive the file is on. A terminal file can be opened with the reserved word PRIORITY, which puts its requests ahead of other terminal file requests.

Terminal devices

The same I/O statements drive POS hardware. Besides OPEN, WRITE, READ and CLOSE, the language has device statements such as CLEARS (clear a display), LOCATE (position the cursor), WAIT (pause for a number of milliseconds), LOCKDEV/UNLOCKDEV, and the GETLONG and PUTLONG functions for reading and setting device status words. The following short program writes two lines to a 4683 two-line display and stops. It uses only statements that appear in IBM’s 1996 sample programs, but it has not been compiled or run:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
%ENVIRON T
! A terminal program: greet the customer on the 2x20 display.
INTEGER*2 DISPLAY
ON ERROR GOTO ERR.HNDLR
DISPLAY = 1
OPEN "ANDISPLAY:" AS DISPLAY
CLEARS DISPLAY
WRITE #DISPLAY; "HELLO, WORLD"
LOCATE #DISPLAY; 2,1
WRITE #DISPLAY; "WELCOME TO THE STORE"
WAIT; 2000
CLOSE DISPLAY
STOP
ERR.HNDLR:
! Prevent recursion, then end.
ON ERROR GOTO END.PROG
END.PROG:
STOP
END

System services

The operating system provides services as functions in link libraries, declared in BASIC with FUNCTION ... EXTERNAL. ADXSTART and ADXPSTAR start background applications in the store controller, ADXAUTH handles operator authorization, and ADXSERVE requests other application services. Applications can send messages to one another through pipes, which IBM calls Pipe Routing Services. IBM also offered an optional source-level debugger, the IBM 4680 Application Debugger, available by RPQ, and LINK86 writes the .DBG file it uses.

Evolution

PeriodPlatformNotes
1986IBM 4680 OS Version 14680 BASIC (5669-034) announced in January with the 4680 Store System, based on DRI’s CBASIC compiler, LINK-86 and LIB-86
late 1980s to early 1990s4680 OS Versions 1-4Wikipedia lists Version 1 Releases 1-3 and Versions 2, 3 and 4, without dates. IBM’s December 1986 and 1987 letters require Version 1 Release 3
1993-94IBM 4690 OS Version 1FlexOS 2.32 base; announced mid-1993, generally available March 1994 according to Wikipedia. 4680 BASIC carried forward unchanged in name
by 19964690 OS Version 1 Release 2Programming Guide documents medium, big and large memory models, C and COBOL interfaces, and an IBM DOS environment on the controller
late 1990s-2000s4690 OS Versions 2-6Java added beside BASIC and C; Wikipedia ties Java support to Version 2 but gives no dates for Versions 2-5. Wikipedia says Java applications could run concurrently with existing CBASIC or C applications
2012-2016IBM, then Toshiba, 4690 OS V6SC30-3356 still part of the V6 library in 2012; Toshiba V6R4 (2014) and V6R5 (2016)

IBM’s 1996 guide shows the 4690 version of the language working with its new environment rather than replacing it. Terminal device chapters say devices “can also be programmed using the C language”, but they still use 4680 BASIC for every example. Where the language lacked something, IBM supplied a library routine. For example, “the CBASIC language does not permit reading from the printer”, so a FISREAD routine in a separate library reads data back from the Model 3 fiscal printer.

Current Relevance

IBM 4680 BASIC is a historical language, but it reached further into the present than most. Retail chains used 4690 OS for decades. Wikipedia cites an industry estimate that 4690 still had 12% of the POS client market in June 2005, when IBM began moving customers to IBM Retail Environment for SUSE (IRES). IBM sold its Retail Store Solutions business to Toshiba TEC under an agreement announced on 17 April 2012. Toshiba continued 4690 OS with Version 6 Release 4 in January 2014 and Version 6 Release 5 in January 2016.

According to Wikipedia, Toshiba launched TCx Sky, a Linux-based successor developed with Wind River, in May 2018 and stopped offering 4690 OS to new customers soon afterwards, while continuing to support existing installations under service contracts. No public Toshiba documentation was found that says whether TCx Sky runs 4680 BASIC programs, so this page makes no claim either way.

There is no free compiler, emulator or Docker image. The compiler was a licensed IBM product that ran only under 4680 OS and 4690 OS. The surviving public documentation is mainly IBM announcement letters and 4690 manuals uploaded to the Internet Archive, plus copies of the IBM 4680 BASIC: Language Reference on document-sharing sites. IBM’s own 4690 V6 PDFs on its public download server have been replaced by notices that the documents must now be requested from Toshiba Global Commerce Solutions.

Why It Matters

4680 BASIC is an example of a 1970s microcomputer language finding a long second career in a vertical market. CBASIC began under CP/M as a business BASIC. Through Digital Research’s deal with IBM it became the language of the checkout lane, and it went on running retail POS systems well after CP/M had disappeared.

It also shows how a language for appliances differs from one for general-purpose computers. Its distinctive parts are not its syntax but its environment: terminal and controller memory models, devices opened as files, keyed files kept on the store controller, and error handlers that keep a cash register working. Developers coming to 4690 in the 2000s worked with a compiler, linker and librarian whose ancestry goes back through IBM’s 1986 4680 to Digital Research’s CBASIC.

Timeline

1986
On 8 January IBM announces the 4683 Point-of-Sale Terminal for the new IBM 4680 Store System. The announcement says users may buy IBM's General Sales Application or "write their own application program using the IBM 4680 Basic Language licensed program (5669-034)"
1986
Digital Research's March European Review reports that IBM chose Concurrent DOS-286 for the 4680, and describes IBM 4680 BASIC as a new implementation based on DRI's CBASIC Compiler, LINK-86 and LIB-86. It says IBM's General Sales Application Program (GSAP) is written in IBM 4680 BASIC
1986
IBM's 16 December announcement of 4683 enhancements lists the 4680 General Sales Application, Supermarket Application and Chain Drug Sales Application, or programs written by the customer "using IBM 4680 BASIC (5669-034)". It requires 4680 Operating System Version 1 Release 3
1993
IBM announces the 4690 Operating System, based on Digital Research's FlexOS 2.32, as the successor to 4680 OS. Wikipedia dates the announcement to July 1993, although the IBM letter it cites (293-281) is dated 1 June 1993, and gives general availability as 25 March 1994. Applications written in IBM 4680 BASIC carry over, and the language keeps its 4680 name
1996
IBM's July 1996 edition of the 4690 Store System Programming Guide (SC30-3602-02) gives a full chapter to Designing Applications with IBM 4680 BASIC. It documents medium and big memory models for terminals and a large model for store controllers, and offers Metaware High C as an alternative language
2012
On 17 April IBM and Toshiba TEC announce that Toshiba TEC will buy IBM's Retail Store Solutions business. IBM's May 2012 library for 4690 OS Version 6 Release 3 still lists the IBM 4680 BASIC: Language Reference (SC30-3356) and a CBASIC runtime library
2016
Toshiba releases 4690 OS Version 6 Release 5 in January. It is the last version of the 4690 operating system line

Notable Uses & Legacy

IBM 4680 General Sales Application (GSAP)

IBM's packaged store application for the 4680, program 5669-031. Digital Research's March 1986 newsletter says GSAP was written in IBM 4680 BASIC and provided price lookup, credit authorisation, item classification and returns, as well as back-office price and description changes, sales analysis and store accounting reports.

Retailer-written POS applications

IBM sold 4680 BASIC so that retailers could write their own programs instead of buying IBM's. The 1986 announcement letters offer it as the alternative to the General Sales, Supermarket and Chain Drug Sales applications, and DRI described it as permitting "fast development of retailer-specific applications".

4683 terminal device programming

IBM's 4690 Programming Guide uses IBM 4680 BASIC to document every terminal device driver, with sample programs that open devices such as ANDISPLAY:, CDRAWER: and IOPROC: as files. They drive the 2x20 display, cash drawer, coin dispenser, scale, magnetic stripe reader, check printer and fiscal printer.

Boots pilot installation

Digital Research reported in March 1986 that Boots plc had announced, at a February press conference held jointly with IBM in London, that the first 4680 Store System site in Europe would be a pilot at its Peterborough store. Boots expected to put 4680 systems into 170 of its major stores within three years. The report does not say which applications Boots ran.

Language Influence

Influenced By

CBASIC

Running Today

Run examples using the official Docker image:

docker pull
Last updated: