Git Product home page Git Product logo

ice-9's Introduction

The ICE-9 virtual machine specification

Instruction set

ICE-9 is a simple stack-based virtual machine, containing the following instructions.

c/n -- push constant at index n to the stack

e -- pop and echo the top item on the stack

+ -- pop the top two elements on the stack, and push their sum

r -- return, or exit if at bottom of the call stack (REQUIRED AT END OF PROGRAM)

= -- push 1 if the top two elements are equal, 0 otherwise

j/n -- set PC to n if top of stack (popped) equals 1

g/n -- goto n

x/n -- call subroutine at n, pushing a new stack frame

s/n -- set variable n to the value at the top of the stack

v/n -- push the value of variable n

* -- multiple the top two elements, pushing their product

- -- subtract the top two elements, pushing their difference

> -- greater than (2nd greater than first)

< -- less than (2nd less than first)

| -- or

& -- and

! -- not

% -- modulo

Implementations

Hydro is the primary implementation of the ICE-9 virtual machine, written in the Liquid templating language.

Freon is an implementation of the ICE-9 virtual machine written in Rust for easier debuging.

Any difference in behaviour between Hydro and Freon is an implementation error.

Plasma

Plasma is a langage that compiles to ICE-9 assembly, which can then be interpreted by liquid.

Here is some sample code. Note that the syntax is highly unstable. This code has been tested and runs successfully when compiled / interpreted.

candidate = 2;

while candidate < 1000 {
  prime? = 1;
  divisor = 2;

  while divisor < candidate {
    if (candidate % divisor) == 0 {
      prime? = 0;
    }
    divisor = divisor + 1;
  }

  if prime? {
    echo candidate;
  }

  candidate = candidate + 1;
}

ice-9's People

Contributors

samdoiron avatar

Stargazers

Tristan Potter avatar Frank Filho avatar Noam Hacker avatar Anthony Clark avatar

Watchers

James Cloos avatar Anthony Clark avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.