Est. 1983 Intermediate

Mouse 83

The revised Mouse of Peter Grogono's 1983 book Mouse: A Language for Microcomputers: a one-character-per-command stack language with comparisons, character I/O, comments and tracing, published with complete Pascal and Z80 interpreters.

Created by Peter Grogono

Paradigm Procedural, stack-based (postfix / Reverse Polish notation)
Typing Untyped (all values are integers; characters are handled as ASCII codes)
First Appeared 1983
Latest Version Mouse-83, as published in Mouse: A Language for Microcomputers (Petrocelli Books, 1983)

Mouse 83 (usually written Mouse-83) is the revised version of Mouse, Peter Grogono’s very small interpreted language, as he described it in his 1983 book Mouse: A Language for Microcomputers. Like the original 1979 BYTE version, it is a stack language in which almost every command is a single character and the interpreter reads the program one character at a time. The book version made the language noticeably more practical. It added comparison operators, character input and output, character literals, a remainder operator, comments and execution tracing. It also cleaned up the syntax of assignment and of macro parameters.

The magazine article mainly introduced the language. The book was a complete course: about 150 pages that teach the language, give a set of sample programs, and work through two full interpreters, one in Pascal and one in Z80 assembly language.

History & Origins

From Mouse-79 to Mouse-83

Grogono, then at the Computer Centre of Concordia University in Montreal, first described Mouse in the July 1979 issue of BYTE. The language was descended from MUSYS, which he had written around 1970 for the PDP-8 computers at Electronic Music Studios in London. The Mouse page covers that background in detail.

The first sign of a revision came in BYTE’s June 1980 issue. Replying to Tom Lane’s list of bugs in the published interpreter, Grogono suggested that macro parameters should be numbered (1%, 2%, …) rather than lettered (%A, %B, …). Numbered parameters are one of the changes in the 1983 version.

The 1983 book

Mouse: A Language for Microcomputers was published in 1983 by Petrocelli Books of New York. It has 151 pages and the ISBN 0-89433-201-5, and library catalogues file it under the subject “Mouse (Computer program language)”. The book has the same title as the 1979 article, so enthusiasts call the two dialects Mouse-79 and Mouse-83 to tell them apart. The CodeArchaeology encyclopedia lists them as separate entries.

The book itself has not been found in any online archive, so the details on this page come from David G. Simpson’s Mouse-83 documentation. That includes a transcription of the book’s Pascal interpreter “with corrections” and the book’s example programs, listed with their page numbers.

Design Philosophy

Mouse-83 keeps the original design: the smallest interpreter that can still support structured programming, local variables, recursion and parameter passing.

  • One character, one action. The interpreter fetches a character, acts on it and moves on. There is no tokenizer and no parser. The only table is the one the Pascal interpreter builds before it runs, which records where each macro definition starts.
  • Postfix everything. Expressions use Reverse Polish notation, so the interpreter does not need precedence rules.
  • Single-letter names. Variables and macros are named A to Z. The reference interpreter folds lower case to upper case, so a and A are the same variable.
  • Structured control only. There are conditionals, loops with exits, and macros. There is no goto.

Mouse-83 adds conveniences that the 1979 version lacked: real comparison operators, comments and a trace facility. These make programs easier to write and debug without changing how the interpreter works.

Key Features

What changed from Mouse-79

FeatureMouse-79Mouse-83
AssignmentX 17 = (address, then value, then =)17 X: (value, then address, then :)
End of program$$$
Comparisonsnone (tests mean “greater than zero”)<, =, > push 1 or 0
Macro parameters%A, %B, …1%, 2%, …
Character I/Onone?' reads a character, !' prints one
Character literalnone'C pushes the ASCII code of C
Remaindernone\
Commentsnone~ to end of line
Tracingnone{ turns tracing on, } turns it off

Because = now means “equal to”, assignment moved to :. The operand order also flipped, so the value comes first and the address second.

Symbol summary

SymbolAction
numberPush the number
+ - * /Add, subtract, multiply, integer divide
\Remainder
? / ?'Read a number / read a character (as its ASCII code)
! / !'Print a number / print a character
"..."Print a string; a ! inside the string prints a new line
letterPush the address of a variable (A = 0 … Z = 25 in the current environment)
:Store: the value goes into the address on top of the stack
.Fetch: replace an address with the value stored there
< = >Compare the top two values; push 1 if true, 0 if false
[ ... ]Run the enclosed code if the popped value is greater than zero
( ... )Loop forever
^Leave the innermost loop if the popped value is zero or negative
#X,p1,p2;Call macro X with text parameters
$X ... @Define macro X; @ returns
1%, 2%, …Substitute the first, second, … actual parameter
{ / }Tracing on / off
~Comment to end of line
$End of program

Program layout

The interpreter stops at the first $ it meets during execution, and macro definitions also start with $. As a result, a program with macros has no separate terminator: the main program simply runs into the first $X definition. The Tower of Hanoi program below is laid out that way. A program without macros ends with a lone $.

Local variables and recursion

Each macro call gets a fresh set of 26 variables. The reference interpreter does this by adding an offset to every variable address, which is why the letters map to the numbers 0–25 within the current environment. Grogono’s Pascal interpreter has room for ten such variable spaces and reports “Data space exhausted” if a program goes deeper than that. Its calculation stack and environment stack each hold 20 entries. Simpson’s C port keeps the same design with larger limits.

Parameters are passed as text, not values. When the macro reaches 1%, the interpreter switches back to the caller’s environment and runs the first argument’s characters there. Because of that, an argument like N. 1 - is evaluated against the caller’s N, not the macro’s own.

Examples

The examples below were tested with David G. Simpson’s C interpreter for Mouse-83.

Hello, World!

A ! inside a string prints a new line, so the exclamation mark has to be printed as a character code:

1
2
"Hello, World" 33 !' "!"
$

Squares of 1 to 10

This example is from Simpson’s Mouse-83 tutorial. The comparison operators make the exit test straightforward:

1
2
3
4
1 N:              ~ initialize N to 1
( N. N. * ! " "   ~ begin loop; print squares of numbers
  N. 10 - 0 < ^   ~ exit loop if N >= 10
  N. 1 + N: ) $   ~ increment N and repeat loop

Recursive factorial

Each call to F has its own N, so recursion works without any extra effort:

1
2
3
4
~ factorial by recursion
#F,6; !
$F 1% N: N. 1 < [ 1 @ ]
   #F,N. 1 -; N. * @

This prints 720.

Tower of Hanoi (from the book, pp. 81–82)

Here the parameters are strings, so 2%, 3% and 4% pass the peg names along unchanged:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
~ Tower of Hanoi
( "!How many disks? " ? d: d. 0 > ^
   #H,d., "left","right","middle"; )
$H 1% d:
   d. 1 = [ #M,2%,3%; @ ]
   d. 1-d:
   #H,d.,2%,4%,3%;
   #M,2%,3%;
   #H,d.,4%,3%,2%; @
$M "Move " 1% " to " 2% "!" @

Evolution

PeriodDevelopment
1979Mouse-79 published in BYTE
1980Grogono proposes numbered macro parameters in BYTE
1983Mouse-83 published in book form with Pascal and Z80 interpreters
2002Simpson’s ANSI C interpreter for Mouse-83; Mouse-2002 extension based on it
2007Updated C and Windows builds from Simpson; Bradley’s CP/M interpreter based on the book’s Z80 code

No later revision by Grogono himself appears to have been published; development after Mouse-83 came from hobbyists. The largest change is Simpson’s Mouse-2002, which makes every number floating-point and adds arrays, file I/O, global variables, an | “else” operator, a _ change-sign operator, an & operator for calling named functions, and an interactive mode. Sean Fuller’s “Great MOUSE Programming Language Revival” site and his SourceForge project, registered in December 2001, also promoted the language as a teaching tool.

Current Relevance

Mouse-83 is a historical language with no commercial use, but it is easy to run today. Simpson’s site has the C source for a Mouse-83 interpreter, which builds with any standard C compiler, along with a Windows console binary and the example programs from the book. People who want the original 8-bit experience can use Lee Bradley’s CP/M interpreter, which is derived from Grogono’s Z80 code. Bradley’s own tutorial runs it under CP/M 2.2 in the AltairZ80 simulator.

Mouse-83 is also the version that many modern descriptions of “Mouse” actually describe. The English Wikipedia article, for example, states that its symbol table follows the book version, not the 1979 article.

Why It Matters

Mouse-83 is a complete, small language and is still a useful example for studying interpreters. The book walks through the same design twice, once in Pascal and once in Z80 assembly, so readers can see how a high-level description becomes a working implementation on an 8-bit microprocessor. Many textbook languages are simplified so far that they cannot do anything interesting. Mouse-83 is still small enough to read in an afternoon, yet it handles recursion, local scopes, text-substitution parameters, pointers and arrays. The book’s own examples include a recursive Tower of Hanoi solver and Quicksort.

The revision also shows a language being refined after publication. At least one change, the numbered macro parameters, can be traced to the 1980 BYTE exchange with a reader. The sources consulted do not say what prompted the other additions, such as the comparisons and the tracing operators.

Timeline

1979
Grogono's article "Mouse: A Language for Microcomputers" appears in the July issue of BYTE (pages 198–220) with a Pascal interpreter. This first version later becomes known as Mouse-79
1980
In BYTE's June issue, replying to Tom Lane's "Comment and Correction for Mouse", Grogono suggests numbered macro parameters (1%, 2%, ...) in place of lettered ones (%A, %B, ...). Mouse-83 adopts the change
1983
Petrocelli Books in New York publishes Grogono's 151-page book Mouse: A Language for Microcomputers (ISBN 0-89433-201-5). It defines the revised language, now called Mouse-83, and prints full interpreters in Pascal and Z80 assembly language
2002
David G. Simpson writes an ANSI C interpreter for Mouse-83 based on the book's Pascal version. The source header is dated 3 February 2002. Simpson also bases his own extended dialect, Mouse-2002, on Mouse-83
2007
Simpson's Mouse-83 C source and Windows binary are updated on 1 April 2007. In the same year Lee R. Bradley dates his CP/M Mouse interpreter, which is based on the book's Z80 code. Its banner reads "MOUSE, Peter Grogono, 1983; Lee Bradley, 2007"
2021
Peter Grogono, professor emeritus at Concordia University in Montreal, dies on 16 February, according to his Queens' College, Cambridge memorial

Notable Uses & Legacy

Mouse: A Language for Microcomputers (1983)

Mouse-83 is documented in this book, and much of the book is a worked case study in building an interpreter. It walks through two complete implementations of the same language, one in Pascal and one in Z80 assembly language

The book's example programs

The book includes Mouse-83 programs for the Tower of Hanoi, Quicksort, bubble sort (with an array and with pointers), prime factors, McCarthy's "91" function, expression evaluation and a "MacDonald's Farm" song generator. Simpson has transcribed them with their page numbers

CP/M Mouse interpreter (Lee R. Bradley)

A CP/M interpreter based on the book's Z80 version. Bradley's tutorial shows it running a Hello World program under CP/M 2.2 in Peter Schorn's AltairZ80 simulator

David G. Simpson's C interpreter

A portable ANSI C port of Grogono's Pascal interpreter that raises its fixed limits (for example, 10,000 characters of program text instead of 2,000). It ships with a Windows console binary built with Borland C++

Mouse-2002

Simpson's extension of Mouse-83. It adds floating-point numbers, arrays, file I/O, global variables, an else operator (|), a change-sign operator (_), an & function operator and an interactive mode

Language Influence

Influenced By

Influenced

Mouse-2002

Running Today

Run examples using the official Docker image:

docker pull
Last updated: