GithubHelp home page GithubHelp logo

urm's Introduction

URM Simulator

This repositroy contains URM simulator written in C along with some example URM programs. This was built as a homework for the computability theory class at my university.

About 📖

URM (Unlimited Register Machine) is an abstraction of computing device. As its name suggests the machine has unlimited registers whose values are natural numbers. The machine executes instructions one after another in sequential order unless jump instruction is encountered and its condition is satisfied. URM can execute 4 types of instructions:

  • Zero instruction Z(i) - sets i-th register to zero
  • Successor S(i) - sets the value of i-th register to its successor (increments it by one)
  • Transfer T(i, j) - sets the value of i-th register to the value of j-th register
  • Jump J(i, j, k) - jumps to k-th instruction if contents of the i-th and j-th register match, otherwise it proceeds to the next instruction

The program terminates when reaches the instruction outside of the range of instructions in the program. The result of the computation should be stored in the first register.

The simulator can execute arbitrary URM programs. In addition you can add comments beginning with # and add labels indicating instruction number (e.g. 1: S(3)). These labels are not considered during the execution of the program, so if an instruction is mislabeled it will not affect how the program is executed but you will be warned that the label number doesn't match the instruction number.

When running a simulator you need to provide the path to your program as the first argument and the initial register configuration as subsequent arguments. The rest of the registers are considered to contain 0, but they will not be allocated until a write operation is performed on them.

Getting started ⚙️

git clone https://github.com/AleksaC/urm
cd urm
make
./bin/release/simulator examples/min.txt 7 5 12

This will clone the repo, generate simulator binary in bin/release and run a program that finds the minimum of 3 natural numbers (in this case 7, 3 and 12).

To compile the project in debug mode run:

make debug

You can also build and run the program with the following command:

make run ARGS="path/to/your_program.txt initial_register_configuration"

If you're on windows and want to use make you'll need to use git bash, msys or wsl. Alternatively you can compile the entire project with the following command:

gcc -I ./include -O3 -std=c99 src/urm_simulator.c src/main.c -o bin/simulator

To get debug build replace -O3 with -g.

We've used gcc to compile the project, but you can use clang as a drop-in replacement by setting CC = clang in the Makefile or replacing gcc with clang in the command above.

Once you've compiled the program you can run your own programs or the ones provided in the examples directory.

LICENSE️ ⚖️

license

Contact 🙋‍♂️

urm's People

Contributors

aleksac avatar

Stargazers

 avatar

Watchers

 avatar  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.