Skip to content

tairasu/hack-assembler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nand2Tetris Assembler in Rust

A Nand2Tetris Assembler written in Rust! This assembler is designed to translate assembly language from the Nand2Tetris course (.asm files) into binary code (.hack files), allowing you to run your Hack assembly programs on the Hack hardware platform.

Getting Started

Prerequisites

Before you can use this assembler, you need to have Rust installed on your machine. If you don't have Rust installed, you can download it from the Rust website.

Building the Assembler

To build the assembler, you will use Cargo, Rust's package manager and build system. Simply follow these steps:

  1. Clone this repository to your local machine using Git:

    git clone git@github.com:tairasu/hack-assembler.git
  2. Navigate into the project directory:

    cd hack-assembler
  3. Build the project using Cargo:

    cargo build --release

    The --release flag builds the assembler in release mode, which optimizes the binary for performance.

Running the Assembler

After building the assembler, you can use it to convert .asm files to .hack binary files.

To run the assembler, use the following command:

./rust-assembler <filepath>

Replace <filepath> with the path to your .asm file. The assembler will generate a .hack file in the same directory as your .asm file.

Examples

Assuming you have an assembly file named Max.asm in your current directory, you can assemble it into a binary file named Max.hack with the following command:

./rust-assembler Max.asm

License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgments

  • This project is inspired by the Nand2Tetris course, and it's dedicated to everyone involved in creating and maintaining this resource.