Mouse (programming language)

Last updated

The 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 [4] 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" Check |url= value (help). BYTE. pp. 198–220. Retrieved 18 October 2013.
  2. Lane, Tom; Grogono, Peter (June 1980). "Comment and Correction for Mouse". BYTE. Retrieved 18 October 2013.
  3. 1 2 3 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 the Apple II series of 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 used to invoke it, instead of INT for Integer BASIC.

BASIC Family of programming languages

BASIC is a family of general-purpose, high-level programming languages whose design philosophy emphasizes ease of use. The original version was designed by John G. Kemeny and Thomas E. Kurtz and released at Dartmouth College in 1964. They wanted to enable students in fields other than science and mathematics to use computers. At the time, nearly all use of computers required writing custom software, which was something only scientists and mathematicians tended to learn.

Brainfuck is an esoteric programming language created in 1993 by Urban Müller.

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

Forth is a procedural, stack-oriented programming language and interactive 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, but Forth is more common.

In computer science, threaded code is a programming technique where the code has a form that essentially consists entirely of calls to subroutines. It is often used in compilers, which may generate code in that form or be implemented in that form themselves. The code may be processed by an interpreter or it may simply be a sequence of machine code call instructions.

An esoteric programming language is a programming language designed to test the boundaries of computer programming language design, as a proof of concept, as software art, as a hacking interface to another language, or as a joke. The use of esoteric distinguishes them from languages that working developers use to write software. The creators of most esolangs do not intend them to be used for mainstream programming, although some esoteric features, such as visuospatial syntax, have inspired practical applications in the arts. Such languages are often popular among hackers and hobbyists.

Atari BASIC

Atari BASIC is an interpreter for the BASIC programming language that shipped with the Atari 8-bit family of 6502-based home computers. Unlike most 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, for example.

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.

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 (TI)'s graphing calculators. TI-BASIC is a language family of three different and incompatible versions, released on different products:

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.

Color BASIC is the implementation of Microsoft BASIC that is included in the ROM of the Tandy/Radio Shack TRS-80 Color Computers manufactured between 1980 and 1991. BASIC is a high level language with simple syntax that makes it easy to write simple programs. Color BASIC is interpreted, that is, decoded as it is run.

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.

In computer programming, homoiconicity is a property of some programming languages. A language is homoiconic if a program written in it can be manipulated as data using the language, and thus the program's internal representation can be inferred just by reading the program itself. This property is often summarized by saying that the language treats "code as data".

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 subroutine is a sequence of program instructions that performs a specific task, packaged as a unit. This unit can then be used in programs wherever that particular task should be performed.

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.

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