Mouse (programming language)

Mouse (programming language)

The Mouse programming language is a small computer programming language developed by Dr. Peter Grogono in the late 1970s and early 1980s.[1][2] It was developed as an extension of an earlier language called MUSYS, which was used to control digital and analog devices in an electronic music studio.

Mouse was originally intended as a small, efficient language for microcomputers with limited memory. It is an interpreted, stack-based language and uses Reverse Polish notation. To make an interpreter as easy as possible to implement, Mouse is designed so that a program is processed as a stream of characters, interpreted one character at a time.

The elements of the Mouse language consist of a set of (mostly) one-character symbols, each of which performs a specific function (see table below). Since variable names are limited to one character, there are only 26 possible variables in Mouse (named A-Z). Integers and characters are the only available data types.

Despite these limits, Mouse includes a number of relatively advanced features, including:

  • Conditional branching
  • Loops
  • Pointers
  • Macros (subroutines (which may be recursive))
  • Arrays
  • Code tracing

The design of the Mouse language makes it ideal for teaching the design of a simple interpreter. Much of the book describing Mouse[2] is devoted to describing the implementation of two interpreters, one in Z80 assembly language, the other in Pascal.



The language described here is the later version of Mouse, as described in the Mouse book[2]. This version is an extension of the language described in the original magazine article[1].


The following table describes each of the symbols used by Mouse[2]. Here X refers to the number on the top of the stack, and Y is the next number on the stack.

Symbol Action
<space> No action
$ End of program
<number> Push <number> onto stack
+ Add
- Subtract
* Multiply
/ Integer divide
\ Remainder
 ? Input integer
 ?' Input character
 ! Print integer
 !' Print character
' Push character onto stack
" Print string
<letter> Get variable address
 : Store variable
. Recall variable
< Return 1 if Y < X; else return 0
= Return 1 if Y = X; else return 0
> Return 1 if Y > X; else return 0
[ Start of conditional statement
] End of conditional statement
( Start of loop
) End of loop
^ Exit loop (if false)
# Macro call
@ Exit from macro
 % Macro parameter
, End of actual macro parameter
 ; End of list of macro parameters
{ Start trace
} End trace
~ Comment


Common idioms

These expressions appear frequently in Mouse programs.

X:           ~ store into variable X
X.           ~ recall variable X
X. Y:        ~ assign X to Y
N. 1 + N:    ~ increment N by 1
P. Q. P: Q:  ~ swap values of P and Q
? A:         ~ input a number and store in A
P. !         ~ print variable P


Mouse may input integers or characters. When a character is input, it is automatically converted to its ASCII code.

? X:         ~ input a number and store into X
?' X:        ~ input a character and store its ASCII code into X


Mouse may print integers, characters, or string constants, as shown in these examples. If an exclamation point appears in a string constant, a new line is printed.

X. !             ~ recall number X and print it
X. !'            ~ recall ASCII code X and print character
"Hello"          ~ print string "Hello"
"Line 1!Line 2"  ~ print strings "Line 1" and "Line 2" on two lines


A conditional statement has the general form:

B [ S ]  ~ equivalent to:  if B then S

Here B is an expression that evaluates to 1 (true) or 0 (false), and S is a sequence of statements.


Loops may have one of several forms. Most common are the forms:

(B ^ S)   ~ equivalent to:  while B do S
(S B ^)   ~ equivalent to:  repeat S until (not B)

Here again B is a boolean value (0 or 1), and S is a sequence of statements.

Macro calls

The format of a macro (subroutine) call may be illustrated by the following example. Macro A in this example adds the two parameters passed to it from the main program, and returns the sum on the top of the stack.

#A,p1,p2;     ~ call in main program to macro A
$A 1% 2% + @  ~ macro A (add parameters p1 and p2)

Here p1 and p2 are parameters passed to the macro.

Example programs

This short program prints 'Hello world.'

"Hello world."

This program displays the squares of the integers from 1 to 10.

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


  1. ^ a b Grogono, Peter. "Mouse: A Language for Microcomputers", Byte, July 1979, pp. 198ff.
  2. ^ a b c d Grogono, Peter. Mouse: A Language for Microcomputers. 151 pages. Petrocelli Books, Inc.: 1983. ISBN 0-89433-201-5.

See also

  • FALSE esoteric programming language

External links

Wikimedia Foundation. 2010.

Look at other dictionaries:

  • computer programming language — Introduction       any of various languages for expressing a set of detailed instructions for a digital computer. Such instructions can be executed directly when they are in the computer manufacturer specific numerical form known as machine… …   Universalium

  • Logo (programming language) — LOGO redirects here. For other uses, see LOGO (disambiguation). Logo Paradigm(s) multi paradigm:functional educational, procedural, reflective Appeared in …   Wikipedia

  • Processing (programming language) — Processing Paradigm(s) object oriented Appeared in 2001; 9 years ago (2001) …   Wikipedia

  • Tactile programming language — Tactile programming is the specification, development, interaction with and interpretation of computer programs through a touch centric interface. It is based on the ideas behind visual programming languages, particularly in the interaction and… …   Wikipedia

  • Clarion (programming language) — For other uses, see Clarion. Clarion Developer(s) JPI, Clarion International, SoftVelocity Stable release 8.0 / August 30, 2011; 2 months ago (2011 08 30) Operating system …   Wikipedia

  • Groovy (programming language) — Infobox programming language name = Groovy paradigm = object oriented, scripting year = 2003 designer = JCP developer = Guillaume Laforge (Project Manager and JSR 241 Spec Lead) latest release version = 1.5.7 latest release date = release… …   Wikipedia

  • C Sharp (programming language) — The correct title of this article is C# (programming language). The substitution or omission of the # sign is because of technical restrictions. C# Paradigm(s) multi paradigm: structured, imperative …   Wikipedia

  • History of the Dylan programming language — Dylan programming language history first introduces the history with a continuous text. The second section gives a timeline overview of the history and present several milestones and watersheds. The third section presents quotations related to… …   Wikipedia

  • Mouse (disambiguation) — A mouse is a small rodent. Mouse may also refer to: Contents 1 People 2 Fictional characters 3 Other uses …   Wikipedia

  • Mouse (computing) — A computer mouse with the most common standard features: two buttons and a scroll wheel, which can also act as a third button In computing, a mouse is a pointing device that functions by detecting two dimensional motion relative to its supporting …   Wikipedia