Git Product home page Git Product logo

divarema's Introduction

The DIdactic VAnity REgister MAchine

This is a pet-project interpreter which implements a random access machine as described by Cook and Reckhow.

divarema only implements the machine's basic instructions; the paper linked above also includes a proof regarding a VM built with these instructions which can execute arbitrary programs stored in main memory within some time bounds (so an arbitrarily large program can be executed with a space-bounded instruction and ROM program).

Motivation

This is a pet project to help me learn about models of computation and about Rust (hence didactic and vanity). It's not intended for any other application, but if you get something from it that's great :)

The Machine

divarema reads instructions form a file and executes them. The machine has eight instructions and two kinds of memory. Program memory stores the program being executed and is immutable. Main memory is available to the program and consists of a number (by default, 8) of mutable registers that can hold signed 32-bit integers. Main memory is indexed by integers, starting from 0.

Two special registers control operation and implement arithmetic:

  • The accumulator ACC is the target and source of arithmetic and copy operations
  • The instruction counter IC holds the address (in program-memory) of the next instruction to execute, manipulated by control-flow operations

Instruction Set

Programs for divarema can include the following instructions:

Operation Description Mnemonic
LOAD j ACC <- j ; IC <- IC+2 load
ADD j ACC <- [ACC] + [Xj] ; IC <- IC+2 add
SUB j ACC <- [ACC] - [Xj] ; IC <- IC+2 subtract
STORE j Xj <- [ACC] ; IC <- IC+2 store
JGZ j if AC > 0 then IC <- j else IC <- IC+2 jump-greather-than-zero
READ j Xj <- next input read
PRINT j output [Xj] print
HALT _ stop execution halt

License

This software is licensed under the GNU General Public License v3.0. See LICENSE or license's website for details.

divarema's People

Contributors

nathanielknight avatar

Watchers

 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.