https://github.com/aleksac/urm
URM simulator written in C
https://github.com/aleksac/urm
c simulator urm
Last synced: about 1 year ago
JSON representation
URM simulator written in C
- Host: GitHub
- URL: https://github.com/aleksac/urm
- Owner: AleksaC
- License: mit
- Archived: true
- Created: 2020-05-10T23:32:36.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-11T14:17:06.000Z (over 5 years ago)
- Last Synced: 2025-04-17T08:33:38.086Z (about 1 year ago)
- Topics: c, simulator, urm
- Language: C
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# URM Simulator
This repositroy contains [URM](https://proofwiki.org/wiki/Definition:Unlimited_Register_Machine)
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 ⚙️
```shell script
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:
```shell script
make debug
```
You can also build and run the program with the following command:
```shell script
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:
```shell script
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](https://github.com/AleksaC/urm/tree/master/examples).
## LICENSE️ ⚖️
[](https://github.com/AleksaC/urm/blob/master/LICENSE)
## Contact 🙋♂️
- [Personal website](https://aleksac.me)
-
- aleksacukovic1@gmail.com