The content of this website is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Australia (CC BY-NC-SA 3.0)

MMBasic Overview

MMBasic is a full featured interpreter for the BASIC language.  It's focus is on ease of use and rapid software development.  Commands and code fragments can be tested and quickly modified making for a productive development environment.

This page gives an overview of MMBasic and its capabilities.

Interpreter

Being an interpreter means that MMBasic will decode each statement as the program is running.  This is slower than a compiled program but it means that the language is self contained, you do not need a compiler, operating system or host computer... you just enter your program and run it.

When MMBasic commences running it will present a prompt as shown on the right.

One benefit of an interpreter is that it is possible to test a command at this prompt, without having to create a program. 

The example on the right shows the result of testing the print command and you can test most other commands in this way.

Entering Programs

The traditional method of entering programs into a BASIC interpreter is to prefix each line with a number and MMBasic fully supports this method.  There are a variety of commands like DELETE, LIST, etc that you can use to modify and examine the programs using line numbers.

MMBasic also supports programs that do not use line numbers.  These cannot be edited at the command prompt and need a full text editor.  The Maximite version includes a full screen editor (the EDIT command) and other versions can accept programs edited using a separate editor.

Data Types and Variables

MMBasic supports two data types; floating point numbers and strings.  These can be stored in variables and arrays and can be operated on using the normal BASIC syntax.  Floating point uses the single precision IEEE-754 floating-point format (this is compiler dependent).  Strings can contain characters of any value and have a maximum size of 255 characters.

Variable names can be up to 32 characters long.  Arrays can hold floating point numbers or strings and can have up to eight dimensions.  The size of an array is limited only by the amount of available memory.

Commands, functions and operators

The base implementation of MMBasic has 54 commands, 40 functions and 19 operators.  Extended versions like the Maximite version have added many more commands and functions to support additional features.

The commands include many that are used to control the program flow (IF...THEN, etc) and others to manage the interpreter (SAVE, LIST, etc) or input/output data (INPUT, PRINT, etc).  Functions include string and arithmetic functions like SIN(), EXP(), etc. 

MMBasic has a particularly rich selection of string functions and operators that allow programs to pull apart strings, compare them and manipulate them in various ways.

Program Constructs

MMBasic supports the traditional BASIC constructs:

and also a number of modern structured programming constructs:

Extended Functionality

The Maximite and Colour Maximite versions of MMBasic support a much larger range of features.  The short list includes:

A more detailed description of these can be found at the official Maximite web page.

Internal Structure

When a program is loaded or entered at the prompt it is tokenised so that commands, functions and operators are converted to single byte tokens.  These save space but the main benefit is that the interpreter can run much faster because executing a command only requires the use of the token value to index a table to find the code that implements that particular function.  Line numbers (if used) are also converted into 16 bit integers when the program is stored in memory,

Other than this the program is maintained in memory in ASCII format.  When the program is saved or listed MMBasic will automatically decode the tokens and line numbers so that the user is unaware of the compressed memory format.

When the program is run MMBasic will build a table of pointers to any user defined subroutines, functions and labels in the program.  These are used to immediately jump to the correct position in program memory whenever one of these elements are used.

Memory allocation is automatically maintained by MMBasic.  Memory for the program, variables, arrays and general memory use (the heap) is allocated from a single memory pool which is dynamically managed as the program is run.

Standards

MMBasic was designed to mimic the original Microsoft BASIC (also known as MBASIC, BASICA or GW-BASIC) which was supplied with the Tandy TRS-80, Commodore 64 and the early IBM personal computers.

In addition MMBasic supports many modern structured programming constructs.  These constructs and most of the language substantially meets the specifications in the ANSI Standard for Full BASIC (X3.113-1987) or ISO/IEC 10279:1991.  

In the PIC32 versions arithmetic operations comply with the IEEE-754 standard.