Mouse (programming language)

Last updated

The Mouse (sometimes written as MOUSE) programming language is a small computer programming language developed by Dr. Peter Grogono in the late 1970s and early 1980s. [1] [2] [3] 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.

Contents

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:

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

Details

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

Symbols

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

SymbolAction
<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

Expressions

Common idioms

These expressions appear frequently in Mouse programs.

X:           ~ store into variable X X.           ~ recall variable X X. Y:        ~ copy X into 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 

Input

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 

Output

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 

Conditionals

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

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

Notes

  1. 1 2 Grogono, Peter (July 1979). mii/n197/mode/2up "Mouse / A Language for Microcomputers". BYTE. pp. 198–220. Retrieved 18 October 2013.{{cite news}}: Check |url= value (help)
  2. Lane, Tom; Grogono, Peter (June 1980). "Comment and Correction for Mouse". BYTE. Retrieved 18 October 2013.
  3. 1 2 3 4 Grogono, Peter. Mouse: A Language for Microcomputers. 151 pages. Petrocelli Books, Inc.: 1983. ISBN   0-89433-201-5.

Related Research Articles

Applesoft BASIC is a dialect of Microsoft BASIC, developed by Marc McDonald and Ric Weiland, supplied with Apple II 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">BASIC</span> Family of programming languages

BASIC is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College in 1963. They wanted to enable students in non-scientific fields to use computers. At the time, nearly all computers required writing custom software, which only scientists and mathematicians tended to learn.

<span class="mw-page-title-main">Computer program</span> Instructions a computer can execute

A computer program is a sequence or set of instructions in a programming language for a computer to execute. It is one component of software, which also includes documentation and other intangible components.

<span class="mw-page-title-main">Common Lisp</span> Programming language standard

Common Lisp (CL) is a dialect of the Lisp programming language, published in American National Standards Institute (ANSI) standard document ANSI INCITS 226-1994 (S2018). The Common Lisp HyperSpec, a hyperlinked HTML version, has been derived from the ANSI Common Lisp standard.

Forth is a stack-oriented programming language and interactive integrated development environment designed by Charles H. "Chuck" Moore and first used by other programmers in 1970. Although not an acronym, the language's name in its early years was often spelled in all capital letters as FORTH. The FORTH-79 and FORTH-83 implementations, which were not written by Moore, became de facto standards, and an official technical standard of the language was published in 1994 as ANS Forth. A wide range of Forth derivatives existed before and after ANS Forth. The free and open-source software Gforth implementation is actively maintained, as are several commercially supported systems.

<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 Atari 8-bit 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.

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.

dc is a cross-platform reverse-Polish calculator which supports arbitrary-precision arithmetic. It was written by Lorinda Cherry and Robert Morris at Bell Labs. It is one of the oldest Unix utilities, preceding even the invention of the C programming language. Like other utilities of that vintage, it has a powerful set of features but terse syntax. Traditionally, the bc calculator program was implemented on top of dc.

BASIC-PLUS is an extended dialect of the BASIC programming language that was developed by Digital Equipment Corporation (DEC) for use on its RSTS/E time-sharing operating system for the PDP-11 series of 16-bit minicomputers in the early 1970s through the 1980s.

TI-BASIC is the official name of a BASIC-like language built into Texas Instruments' graphing calculators. TI-BASIC is a language family of three different and incompatible versions, released on different products:

FOCAL is an interactive interpreted programming language based on JOSS and mostly used on Digital Equipment Corporation (DEC) Programmed Data Processor (PDP) series machines.

HP Time-Shared BASIC is a BASIC programming language interpreter for Hewlett-Packard's HP 2000 line of minicomputer-based time-sharing computer systems. TSB is historically notable as the platform that released the first public versions of the game Star Trek.

Galaksija BASIC was the BASIC interpreter of the Galaksija build-it-yourself home computer from Yugoslavia. While being partially based on code taken from TRS-80 Level 1 BASIC, which the creator believed to have been a Microsoft BASIC, the extensive modifications of Galaksija BASIC—such as to include rudimentary array support, video generation code and generally improvements to the programming language—is said to have left not much more than flow-control and floating point code remaining from the original.

<span class="mw-page-title-main">Control table</span> Data structures that control the execution order of computer commands

Control tables are tables that control the control flow or play a major part in program control. There are no rigid rules about the structure or content of a control table—its qualifying attribute is its ability to direct control flow in some way through "execution" by a processor or interpreter. The design of such tables is sometimes referred to as table-driven design. In some cases, control tables can be specific implementations of finite-state-machine-based automata-based programming. If there are several hierarchical levels of control table they may behave in a manner equivalent to UML state machines

The structure of the Perl programming language encompasses both the syntactical rules of the language and the general ways in which programs are organized. Perl's design philosophy is expressed in the commonly cited motto "there's more than one way to do it". As a multi-paradigm, dynamically typed language, Perl allows a great degree of flexibility in program design. Perl also encourages modularization; this has been attributed to the component-based design structure of its Unix roots, and is responsible for the size of the CPAN archive, a community-maintained repository of more than 100,000 modules.

In computer programming, a function is a callable unit of software logic that has a well-defined interface and behavior and can be invoked multiple times.

SCELBAL, short for SCientific ELementary BAsic Language, is a version of the BASIC programming language released in 1976 for the SCELBI and other early Intel 8008 and 8080-based microcomputers like the Mark-8. Later add-ons to the language included an extended math package and string handling. The original version required 8 kB of RAM, while the additions demanded at least 12 kB.

SUPER BASIC, sometimes SBASIC for short, is an advanced dialect of the BASIC programming language offered on Tymshare's SDS 940 systems starting in 1968 and available well into the 1970s.

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

Acorn System BASIC and Atom BASIC are two closely related dialects of the BASIC programming language developed by Acorn Computers for their early microcomputers like the Acorn System 3 and Acorn Atom. Developed in-house, they have a number of significant idiosyncrasies compared to most BASIC dialects of the home computer era.