IBM BASIC

The IBM Personal Computer Basic, commonly shortened to IBM BASIC, is a programming language first released by IBM with the IBM Personal Computer, Model 5150 (IBM PC) in 1981. IBM released four different versions of the Microsoft BASIC interpreter, licensed from Microsoft for the PC and PCjr. They are known as Cassette BASIC, Disk BASIC, Advanced BASIC (BASICA), and Cartridge BASIC. Versions of Disk BASIC and Advanced BASIC were included with IBM PC DOS up to PC DOS 4. In addition to the features of an ANSI standard BASIC, the IBM versions offered support for the graphics and sound hardware of the IBM PC line. Source code could be typed in with a full-screen editor, and very limited facilities were provided for rudimentary program debugging. IBM also released a version of the Microsoft BASIC compiler for the PC, concurrently with the release of PC DOS 1.10 in 1982.
Background.
IBM licensed Microsoft BASIC for the IBM Personal Computer, despite already having its own version of BASIC for the company's mainframes. Don Estridge said, "Microsoft BASIC had hundreds of thousands of users around the world. How are you going to argue with that?"
IBM Cassette BASIC.
"IBM Cassette BASIC" came in 32 kilobytes (KB) of read-only memory (ROM), separate from the 8 KB BIOS ROM of the original IBM PC, and did not require an operating system to run. Cassette BASIC provided the default user interface invoked by the BIOS through INT 18h if there was no floppy disk drive installed, or if the boot code did not find a bootable floppy disk at power up. The name Cassette BASIC came from its use of cassette tapes rather than floppy disks to store programs and data. Cassette BASIC was built into the ROMs of the original PC and XT, and early models in the PS/2 line. It only supports loading and saving programs to the IBM cassette tape interface, which is unavailable on models after the original Model 5150. The entry-level version of the 5150 came with just 16 KB of random-access memory (RAM), which was sufficient to run Cassette BASIC. However, Cassette BASIC was rarely used because few PCs were sold without a disk drive, and most were sold with PC DOS and sufficient RAM to at least run Disk BASIC—many could run Advanced BASIC as well. There are three versions of Cassette BASIC: C1.00 (found on the early IBM PCs with 16k-64k motherboards), C1.10 (found on all later IBM PCs, XTs, ATs, and PS/2s), and C1.20 (found on the PCjr).
IBM Disk BASIC.
"IBM Disk BASIC (BASIC.COM)" was included in the original IBM PC DOS. Because it uses the 32 KB Cassette BASIC ROM, BASIC.COM did not run on even highly compatible PC clones, such as the Compaq Portable. The name Disk BASIC came from its use of floppy disks as well as cassette tapes to store programs and data. Disk-based code corrected errata in the ROM-resident code and added floppy disk and serial port support.
Disk BASIC can be identified by its use of the letter D preceding the version number. It adds disk support and some features lacking in Cassette BASIC, but does not include the extended sound/graphics functions of BASICA. The primary purpose of Disk BASIC was as a "light" version for IBM PCs with only 48 KB of memory: BASIC.COM would then have about 23 KB free for user code, whereas BASICA would only have about 17 KB. By 1986, all new PCs shipped with at least 256k and DOS versions after 3.00 reduced Disk BASIC to only a small stub that called BASICA.COM for compatibility with batch files. Even with all this excess RAM, BASIC would still only allocate and manage just under 61 KB for user programs, whether it was Cassette BASIC, BASIC.COM or BASICA.
IBM Advanced BASIC.
"IBM Advanced BASIC (BASICA.COM)" was also included in the original IBM PC DOS, and required the ROM-resident code of Cassette BASIC. It adds functions such as diskette file access, storing programs on disk, monophonic sound using the PC's built-in speaker, graphics functions to set and clear pixels, draw lines and circles, and set colors, and event handling for communications and joystick presses. BASICA will not run on non-IBM computers (even so-called "100% compatible" machines) or later IBM models, since those lack the needed ROM BASIC.
BASICA versions are the same as their respective DOS, beginning with v1.00 and ending with v3.30. The early versions of BASICA do not support subdirectories and some graphics commands functioned slightly differently. As an example, if the LINE statement was used to draw lines that trailed off-screen, BASIC merely intersects them with the nearest adjacent line while in BASIC 2.x and up, they go off the screen and do not intersect. The PAINT command in BASIC 1.x begins filling at the coordinate specified and expands outward in alternating up and down directions while in BASIC 2.x it fills everything below the starting coordinate and then after finishing, everything above it. BASIC 1.x's PAINT command also makes use of the system stack for storage and when filling in complex areas, it is possible to produce an OVERFLOW error. To remedy this, the CLEAR statement can be used to expand BASIC's stack (128 bytes is the default size). BASIC 2.x does not use the stack when PAINTing and thus is free of this problem.
Compaq BASIC 1.13 was the first standalone BASIC for the PC (that did not require Cassette BASIC to run) as well as the only version of BASIC besides IBM BASICA 1.00 and 1.10 to use FCBs and include the original LINE statement with intersecting lines (the PAINT statement in Compaq BASIC 1.13 worked like in all later versions of BASICA/GW-BASIC, using the new fill algorithm and no stack).
Early versions of PC DOS include several sample BASIC programs demonstrating the capabilities of the PC, including the BASICA game "DONKEY.BAS".
GW-BASIC is identical to BASICA, with the exception of including the Cassette BASIC code in the program, thus allowing it to run on non-IBM computers and later IBM models that lack Cassette BASIC in ROM.
IBM PCjr Cartridge BASIC.
A ROM cartridge version of BASIC was only available on the IBM PCjr, shipped in 1984, and supports the additional graphics modes and sound capabilities possible on that machine. It is a superset of advanced BASIC. Cartridge BASIC can only operate within the first 128 KB of memory on the PCjr and will not work with expansion RAM, "i.e.", the DEF SEG function cannot be used to point to memory segments above &H1FF0.
Cartridge BASIC is activated by typing BASICA at the DOS prompt. Conversely, IBM BASICA versions 2.1 and up will refuse to run if it detects a PCjr, but can be patched to work around this.
Operation.
Cassette BASIC loads when a PC or PCjr is booted without a bootable disk or cartridge. Disk BASIC and Advanced BASIC load when their command name (BASIC and BASICA respectively) is typed at a DOS command prompt (except PCjr, which activates Cartridge BASIC instead), with some optional parameters to control allocation of memory. When loaded, a sign-on identification message displays the program version number, and a full-screen text editor starts (see images, right). The function keys are assigned common commands, which display at the bottom of the screen. Commands may be typed in to load or save programs, and expressions can be typed in and executed in direct (immediate) mode. If a line of input starts with a number, the language system stores the following line of text as part of program source, allowing a programmer to enter in an entire program line by line, entering line numbers before each statement. When listed on screen, lines are displayed in order of increasing line number. Changes can be made to a displayed line of program source code by moving the cursor to the line with the cursor keys, and typing over the on-screen text. Program source is stored internally in a tokenized form, where reserved words are replaced with a single byte token, to save space and execution time. Programs may be saved in compact tokenized form, or optionally saved as DOS ASCII text files that can be viewed and edited with other programs. Like most other DOS applications, IBM BASIC is a text-mode program and has no features for windows, icons, mouse support, or cut-and-paste editing.
Legacy.
GW-BASIC, launched in 1983, is a disk-based Microsoft product that was distributed with non-IBM MS-DOS computers, and supports all the graphics modes and features of BASICA on computers that do not have IBM Cassette BASIC.
The successor to BASICA for MS-DOS and PC DOS versions, now discontinued, is QBasic, launched in 1991. It is a stripped-down version of the Microsoft QuickBASIC compiler: QBasic is an interpreter and cannot compile source files, while QuickBASIC can compile and save the programs in the .EXE executable file format.