ArticleslgStudy

computer science

MBASIC

MBASIC is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand MBASIC rather than just read about it. In short: 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 — main illustration
MBASIC — illustration

Key takeaways

  • MBASIC belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect MBASIC to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of MBASIC from memory before moving on to harder problems.

Reference excerpt

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. MBASIC, like its predecessor family of 8-bit interpreters Microsoft BASIC, were heavily inspired by Digital Equipment Corporation PDP-10's BASIC-PLUS, albeit simpler (less structured) and slower (no partial compilation).

Environment

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. 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:

8-bit character data, in strings of length 0 to 255 characters; 16-bit integers; 32-bit floating point (single precision), equivalent to six decimal digits, with a two-digit exponent; 64-bit floating point (double precision), equivalent to sixteen decimal digits, with a two-digit exponent. 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.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with MBASIC

Start with the simplest possible case. Write down what MBASIC claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to MBASIC before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about MBASIC ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of MBASIC

In research
MBASIC appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses MBASIC in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
MBASIC is common in secondary-school and first-year university syllabi. It links to neighbouring topics BASIC programming language family, CP/M software, Discontinued Microsoft BASICs, so understanding it makes those chapters shorter.
In everyday life
Look for MBASIC outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “MBASIC” →

How to study MBASIC in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what MBASIC means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain MBASIC out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is MBASIC in simple terms?

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.

Why does MBASIC matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study MBASIC?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on MBASIC.

Tags

  • BASIC programming language family
  • CP/M software
  • Discontinued Microsoft BASICs
  • Microsoft programming languages

Keep exploring