Skip to content

hashcatHitman/hack-vm-translator

Hack VM Translator

unsafe forbidden dependency badge


A translator that translates programs written in the Hack VM language into Hack assembly instructions. Based on the nand2tetris course, and written in Rust.

Getting Started

You'll need to install Rust and its package manager, Cargo, on your system. Please refer to the official recommended Rust installation method for your system - this will most likely be through Rustup.

Note that you may need to use the nightly version of Rust. If you're using Rustup you can accomplish this like so:

rustup toolchain install nightly
rustup default nightly

You should also have some version of git installed. You can refer to the Git documentation if you need help with that.

Clone the repository and navigate inside it:

git clone https://github.com/hashcatHitman/hack-vm-translator.git
cd hack-vm-translator

If you'd like to read the documentation, the recommended way to do so is with:

cargo doc --document-private-items --open

Which will open the documentation in your browser.

To build the translator binary, you can do:

cargo build --profile dev

Cargo will download the dependencies and compile the binary. It will be located at ./target/debug/hack-vm-translator or ./target/debug/hack-vm-translator.exe, depending on your system.

Though relative pathing seems to work fine, for the best experience it is recommended to keep your *.vm files and the translator in the same directory. If you are doing so and are in the directory yourself, you can translate a *.vm file to the equivalent *.asm file like so:

./hack-vm-translator Foo.vm

Where Foo can be variable, but should remain valid Unicode.

About

A VM translator that parses Hack VM commands and generates Hack assembly.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Languages