MBASIC

Last updated
MBASIC
Paradigm imperative
Designed by Microsoft
Developer Microsoft
OS CP/M
Website www.microsoft.com
Influenced by
BASIC

MBASIC is the Microsoft BASIC implementation of BASIC for the CP/M operating system. MBASIC is a descendant of the original Altair BASIC interpreters that were among Microsoft's first products. MBASIC was one of the two versions of BASIC bundled with the Osborne 1 computer. The name "MBASIC" is derived from the disk file name MBASIC.COM of the BASIC interpreter.

Contents

Environment

MBasic 5.21 running on a Z80 CP/M system displayed on a monochrome monitor typical for that time MBasic 5.21.jpg
MBasic 5.21 running on a Z80 CP/M system displayed on a monochrome monitor typical for that time

MBASIC version 5 required a CP/M system with at least 28 KB of random-access memory (RAM) and at least one diskette drive.

Unlike versions of Microsoft BASIC-80 that were customized by home computer manufacturers to use the particular hardware features of the computer, MBASIC relied only on the CP/M operating system calls for all input and output. Only the CP/M console (screen and keyboard), line printer, and disk devices were available.

MBASIC in the uncustomized form had no functions for graphics, color, joysticks, mice, serial communications, networking, sound, or even a real-time clock function. MBASIC did not fully support the features of the host CP/M operating system, for example, it did not support CP/M's user areas for organizing files on a diskette. Since CP/M systems were typically single-user and stand alone, there was no provision for file or record locking, or any form of multitasking. Apart from these limitations, MBASIC was considered at the time to be a powerful and useful implementation of BASIC.

Features

Language system

MBASIC is an interpreter. Program source text was stored in memory in tokenized form, with BASIC keywords replaced by one-byte tokens which saved memory space and speeded execution. Any line prefixed with a line number was stored as program text; BASIC statements not prefixed with a line number were executed immediately as commands. Programs could be listed on the screen for editing, or saved to disk in either a compressed binary format or as plain ASCII text. Every source line was identified with a number, which could be used as the target of a GOTO or GOSUB transfer. Only line editing commands were provided. [1] It was often beneficial to save a program as plain text and edit it with a full featured editor.

Program text, variables, disk buffers and the CP/M operating system itself all had to share the 64 kilobyte address space of the 8080 processor. Typically when first starting MBASIC there would be less than 32 kB memory available for programs and data, even on a machine equipped with a full 64 kilobytes of RAM. Comment lines, prefixed with the REM keyword or an apostrophe, could be placed in the program text but took up valuable memory space, which discouraged BASIC users from fully documenting their code. To allow larger and more complex programs to be run, later versions of MBASIC supported functions that allowed portions of program text to be read in and executed under program control (the " CHAIN " and MERGE statements). No support for "shell" command execution was provided, though this functionality could be duplicated by a determined programmer.

A particular advantage of MBASIC was the full-text error messages provided for syntax and run-time errors. MBASIC also had a "trace" function that displayed line numbers as they were executed. While this occupied the same screen space as normal program output, it was useful for detecting conditions such as endless loops.

Files and input/output

Data could be read and stored to disk as either sequential files (delimited by the CP/M convention of CR/LF at the end of each line) or else as fixed-record-length random access files, which, given a sufficiently determined programmer, could be used to perform database-type record manipulation. The Microsoft Binary Format for floating point numbers was proprietary to the implementation, which meant that data could only be interchanged with other programs using ASCII text representation or else with extensive programming to convert the binary format.

Variables and data types

MBASIC supported the following data types:

String operators included substring selection, concatenation, assignment, and testing for equality.

Arrays of the above types were allowed with up to 7 dimensions, but no functions or operators worked on arrays; for example, there was no assignment of arrays. Unlike some other BASIC implementations of the time, MBASIC did not provide support for matrix operations, complex numbers, or a decimal (BCD) data type for financial calculations. All floating point operations were carried out in software since typical CP/M systems did not have floating point hardware. The built-in mathematics functions (sine, cosine, tangent, natural log, exponential, square root) only gave single precision results. A software pseudorandom number generator was provided; this relied on the user to key in a seed number to obtain a sequence of numbers useful for games and some simulations. MBASIC permitted but did not require the LET keyword for assignment statements.

Early versions of BASIC on microcomputers were infamous for one- or two-character variable names, which made the meanings of variables difficult to recall in complex programs. MBASIC version 5 allowed identifiers up to 40 characters long, which permitted programmers to give variables readable names.

Program flow control

Program flow control in MBASIC was controlled by IF...THEN...ELSE... conditional tests, WHILE...WEND loops, and GOTO and GOSUB instructions. No CASE statement was available, although an ON...GOTO... (computed GOTO) provided multi-way branches. Subroutines had no parameters and all variables were global. MBASIC did not make structured programming mandatory for programmers and it was easy to write spaghetti code.

PEEKs, POKEs, and user functions

No discussion of BASICs on the 8-bit computers of the late '70s and early '80s would be complete without mentioning the importance of the PEEK and POKE functions for directly reading and writing to memory. Since these systems typically had no memory protection, this allowed a programmer to access portions of the operating system, or functions that would not otherwise be available. This also provided opportunities for user programs to hang the system (by accident, usually). For example, a CP/M programmer might use a POKE function to allow BASIC to switch the console device to the serial port, if the system BIOS supported this. For machines with real-time clocks, a set of PEEK instructions might have been used to access the time.

For more complex operations, MBASIC allowed user-defined functions that could be called from a BASIC program. These were typically placed in a reserved area of memory, or POKEd into string constants, as a series of machine codes (opcodes). MBASIC also provided hardware INP and OUT instructions that read and wrote directly to the 8080 hardware input/output ports. This could be used to control peripheral devices from a BASIC program if the system hardware permitted.

Any MBASIC programs that made use of PEEK and POKE, and of machine code user functions, were not portable between machines without modifications.

Successors to MBASIC

Besides Microsoft's BASIC-80 for CP/M, a variant of MBASIC was also available as for the ISIS-II operating system.

MSX-BASIC is also a well known successor of MBASIC, featuring several extensions specific to the MSX machines.

All the functions of CP/M MBASIC were available in the IBM PC disk-based BASICA or GWBASIC which made migration of programs from CP/M systems to PC-compatibles possible. The tokens used to represent keywords were different, so CP/M programs had to be saved in ASCII source form. Typically screen formatting escape sequences put into the CP/M version would be replaced with the cursor positioning commands found in the PC versions of BASIC, otherwise little rewriting would be needed.

BASCOM

Microsoft sold a CP/M BASIC compiler (known as BASCOM) which used a similar source language to MBASIC. A program debugged under MBASIC could be compiled with BASCOM. Since program text was no longer in memory and the run-time elements of the compiler were smaller than the interpreter, more memory was available for user data. Speed of real program execution increased about 3 fold.

Developers welcomed BASCOM as an alternative to the popular but slow and clumsy CBASIC. Unlike CBASIC, BASCOM did not need a preprocessor for MBASIC source code so could be debugged interactively. [2] A disadvantage was Microsoft's requirement of a 9% royalty for each compiled copy of a program [3] and $40 for hardware-software combinations. The company also reserved the right to audit developers' financial records. Because authors' typical royalty rates for software was 10-25%, InfoWorld in 1980 stated that BASCOM's additional 9% royalty rate "could make software development downright unprofitable", concluding that "Microsoft has the technical solution [to CBASIC's flaws], but not the economic one". [2]

Importance of MBASIC

MBASIC was an important tool during the era of 8-bit CP/M computers. Skilled users could write routines in MBASIC to automate tasks that in modern-day systems would be performed by powerful application program commands or scripting languages. Exchange of useful MBASIC programs was a common function of computer users' groups. Keying in long BASIC listings from a magazine article was one way of "bootstrapping" software into a new CP/M system. At least one compiler for a high-level language was written in MBASIC, and many small games and utility programs ranging from a few lines to a few thousand lines of code were written.

Other uses

MBASIC is also the name of a commercial BASIC compiler for the Microchip Technology PIC microcontroller family developed by Basic Micro, Inc., unrelated to the CP/M interpreter.

Related Research Articles

Applesoft BASIC is a dialect of Microsoft BASIC, developed by Marc McDonald and Ric Weiland, supplied with the Apple II series of computers. It supersedes Integer BASIC and is the BASIC in ROM in all Apple II series computers after the original Apple II model. It is also referred to as FP BASIC because of the Apple DOS command FP used to invoke it, instead of INT for Integer BASIC.

<span class="mw-page-title-main">GW-BASIC</span> Dialect of the BASIC programming language

GW-BASIC is a dialect of the BASIC programming language developed by Microsoft from IBM BASICA. Functionally identical to BASICA, its BASIC interpreter is a fully self-contained executable and does not need the Cassette BASIC ROM found in the original IBM PC. It was bundled with MS-DOS operating systems on IBM PC compatibles by Microsoft.

Turbo Pascal is a software development system that includes a compiler and an integrated development environment (IDE) for the Pascal programming language running on CP/M, CP/M-86, and DOS. It was originally developed by Anders Hejlsberg at Borland, and was notable for its extremely fast compilation. Turbo Pascal, and the later but similar Turbo C, made Borland a leader in PC-based development tools.

<span class="mw-page-title-main">CP/M</span> Discontinued family of computer operating systems

CP/M, originally standing for Control Program/Monitor and later Control Program for Microcomputers, is a mass-market operating system created in 1974 for Intel 8080/85-based microcomputers by Gary Kildall of Digital Research, Inc. CP/M is a disk operating system and its purpose is to organize files on a magnetic storage medium, and to load and run programs stored on a disk. Initially confined to single-tasking on 8-bit processors and no more than 64 kilobytes of memory, later versions of CP/M added multi-user variations and were migrated to 16-bit processors.

<span class="mw-page-title-main">Commodore 128</span> Home computer released in 1985

The Commodore 128, also known as the C128, C-128, or C= 128, is the last 8-bit home computer that was commercially released by Commodore Business Machines (CBM). Introduced in January 1985 at the CES in Las Vegas, it appeared three years after its predecessor, the Commodore 64, the bestselling computer of the 1980s. Approximately 2.5 million C128s were sold during its four year production run.

<span class="mw-page-title-main">Atari BASIC</span> Dialect of the BASIC programming language

Atari BASIC is an interpreter for the BASIC programming language that shipped with the Atari 8-bit family of 6502-based home computers. Unlike most American BASICs of the home computer era, Atari BASIC is not a derivative of Microsoft BASIC and differs in significant ways. It includes keywords for Atari-specific features and lacks support for string arrays, for example.

Microsoft BASIC is the foundation software product of the Microsoft company and evolved into a line of BASIC interpreters and compiler(s) adapted for many different microcomputers. It first appeared in 1975 as Altair BASIC, which was the first version of BASIC published by Microsoft as well as the first high-level programming language available for the Altair 8800 microcomputer.

Integer BASIC is a BASIC interpreter written by Steve Wozniak for the Apple I and Apple II computers. Originally available on cassette for the Apple I in 1976, then included in ROM on the Apple II from its release in 1977, it was the first version of BASIC used by many early home computer owners.

Commodore BASIC, also known as PET BASIC or CBM-BASIC, is the dialect of the BASIC programming language used in Commodore International's 8-bit home computer line, stretching from the PET (1977) to the Commodore 128 (1985).

<span class="mw-page-title-main">Tandy 2000</span> Personal computer by Radio Shack

The Tandy 2000 is a personal computer introduced by Radio Shack in September 1983 based on the 8 MHz Intel 80186 microprocessor running MS-DOS. By comparison, the IBM PC XT used the older 4.77 MHz Intel 8088 processor, and the IBM PC/AT would later use the newer 6 MHz Intel 80286. Due to the 16-bit data bus and more efficient instruction decoding of the 80186, the Tandy 2000 ran significantly faster than other PC compatibles, and slightly faster than the PC AT. The Tandy 2000 was the company's first computer built around an Intel x86 series microprocessor; previous models used the Zilog Z80 and Motorola 6809 CPUs.

The Atari Microsoft BASIC and Atari Microsoft BASIC II variants of the 6502-version of Microsoft BASIC ported to the Atari 8-bit machines. The first version, released 1981, required 32 KB of RAM and was supplied on floppy disk. The second version, released the next year, had most of the code on a ROM cartridge with additional functions on an optional floppy.

<span class="mw-page-title-main">Rainbow 100</span> DEC microcomputer

The Rainbow 100 is a microcomputer introduced by Digital Equipment Corporation (DEC) in 1982. This desktop unit had a monitor similar to the VT220 and a dual-CPU box with both 4 MHz Zilog Z80 and 4.81 MHz Intel 8088 CPUs. The Rainbow 100 was a triple-use machine: VT100 mode, 8-bit CP/M mode, and CP/M-86 or MS-DOS mode using the 8088. It ultimately failed to in the marketplace which became dominated by the simpler IBM PC and its clones which established the industry standard as compatibility with CP/M became less important than IBM PC compatibility. Writer David Ahl called it a disastrous foray into the personal computer market. The Rainbow was launched along with the similarly packaged DEC Professional and DECmate II which were also not successful. The failure of DEC to gain a significant foothold in the high-volume PC market would be the beginning of the end of the computer hardware industry in New England, as nearly all computer companies located there were focused on minicomputers for large organizations, from DEC to Data General, Wang, Prime, Computervision, Honeywell, and Symbolics Inc.

Optimized Systems Software (OSS) was a company that produced disk operating systems, programming languages with integrated development environments, and applications primarily for the Atari 8-bit family of home computers. OSS was best known for their enhanced versions of Atari DOS, Atari BASIC, and the Atari Assembler Editor, all of which were substantially improved over Atari's products, as well as the Action! programming language. OSS also sold some software for the Apple II.

<span class="mw-page-title-main">Beta BASIC</span> BASIC interpreter for the Sinclair Research ZX Spectrum microcomputer

Beta BASIC is a BASIC interpreter for the Sinclair Research ZX Spectrum microcomputer, written by Dr Andrew Wright in 1983 and sold by his one-man software house BetaSoft. BetaSoft also produced a regular newsletter/magazine, BetaNews.

MSX-DOS is a discontinued disk operating system developed by Microsoft's Japan subsidiary for the 8-bit home computer standard MSX, and is a cross between MS-DOS v1.25 and CP/M-80 v2.2.

<span class="mw-page-title-main">LINK 480Z</span> 8-bit microcomputer produced by Research Machines Limited in Oxford, England, during the early 1980s

The LINK 480Z was an 8-bit microcomputer produced by Research Machines Limited in Oxford, England, during the early 1980s.

<span class="mw-page-title-main">DOS</span> Group of closely related IBM PC-compatible operating systems

DOS is a family of disk-based operating systems for IBM PC compatible computers. The DOS family primarily consists of IBM PC DOS and a rebranded version, Microsoft's MS-DOS, both of which were introduced in 1981. Later compatible systems from other manufacturers include DR-DOS (1988), ROM-DOS (1989), PTS-DOS (1993), and FreeDOS (1998). MS-DOS dominated the IBM PC compatible market between 1981 and 1995.

Level I BASIC is a dialect of the BASIC programming language that shipped with the first TRS-80, the TRS-80 Model I.

<span class="mw-page-title-main">BASIC interpreter</span> Interpreter that enables users to enter and run programs in the BASIC language

A BASIC interpreter is an interpreter that enables users to enter and run programs in the BASIC language and was, for the first part of the microcomputer era, the default application that computers would launch. Users were expected to use the BASIC interpreter to type in programs or to load programs from storage.

References

  1. CP/M products providing full-screen editing support required their own installation routines to customize the software for the specific computer terminal used as the system console. No support was provided within CP/M to standardize terminal capabilities.
  2. 1 2 "Editorial". InfoWorld. 1980-08-18. p. 8.
  3. Pournelle, Jerry (December 1980). "BASIC, Computer Languages, and Computer Adventures". BYTE. p. 222. Retrieved 18 October 2013.