Minscode
Jump to navigation
Jump to search
Minscode is a simple langauge based on the Minsky machine. It has 4 registers. A
, B
, and C
are normal numeric registers, c
is a conditional register.
Instructions
Command | Description |
---|---|
+ |
Increment the current register. |
- |
If the current register is greater than 0, decrement it and set the conditional register c to false. Otherwise, set c to true.
|
A |
Switch to register A . This is the default register.
|
B |
Switch to register B .
|
C |
Switch to register C .
|
! |
Negate the conditional register c .
|
(…) |
Run the code enclosed in the parentheses if the conditional register c is true.
|
{…} |
Run the code enclosed in the braces until the conditional register c is true.
|
, |
Output the value of the current register. |
. |
Input a user-supplied number to the current register. |
Programs
Prints out the Fibonacci numbers. Note that the vertical bar separates the actual code, located to the left, from appertaining comments in the right column, the latter portion of which does not represent valid statements in the program.
A, | Print F(0) = 0. B+, | Print F(1) = 1. { | A- | {-C+A} | Set C = A. B- | {-C+A+B} | Set C = A + B, while setting A = B. C, | Print C, which now equals F(n) = F(n-2) + F(n-1). - | {-B+C} | Reset C to zero, while setting B = C. A+- | Set conditional register c to false for infinite loop. } |
This program implements a truth-machine:
. - {+,-} ,
Interpreter
- Common Lisp implementation of the Minscode programming language.