Skip to content

jaredkhan/RegisterMachine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift Register Machine Implementation

This is a Swift implementation of a register machine.

A register machine is a simple, turing-complete computation model. There are many flavours of register machine. The one modelled here has the following very small instruction set:

  • increment(register: RegisterAddress, thenGoTo: Line)
    • Increments the value at the given register address then goes to the specified line of the program.
  • decrement(register: RegisterAddress, success: Line, failure: Line)
    • Decrements the value at the given register address if it is greater than 0 then goes to the given success line of the or goes to the given failure line if the value was already 0.
  • halt
    • Terminates the execution of the program.

The tests provide some brief examples of how to construct programs from these intructions.

Try it by cloning the repository and running:

swift test

About

A Swift implementation of a register machine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages