Minscode

From Esolang
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

+ Increment the current register.
- If the current register is more than 0, decrement it and set the condition to false. Otherwise, set the condition to true.
A Switch to register A. This is the default register.
B Switch to register B.
C Switch to register C.
! Negate c
() Run the code inside if c is true.
{} Run the code inside until c is true.
, Output the value of the current register.
. Input to the current register. 

Programs

Prints out the Fibonacci numbers:

{, { Output A (Initially 0). }
  B-
  {-C+B} { Move the value of B to C. }
  A-
  {-B+C+A} { Move the value of A to B and C. The value of C is now A+B. }
  B-
  {-A+B} { Move the value of B to A. }
  C-
  {-C+B} { Move the value of C to B. }
  A+- { Set the condition to false so the loop keeps going. }
}