This project is a Hack Assembler written in Java as part of the NAND to Tetris course. It reads Hack assembly language, parses it, and writes compatible 16-bit Hack machine code. It fully supports symbols and labels and ignores all white space and comments.
Spoiler alert: this is a fully functioning assembler. If you are taking the course, it is recommended that you try writing an assembler from scratch.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
You need to have Java installed on your machine. You can check if you have Java installed by running the following command in your terminal:
java -version
If you don't have Java installed, you can download it from the official Oracle website.
Clone the repository to your local machine:
git clone https://github.com/brucesdad13/nand2tetris-assembler.git
Navigate to the project directory:
cd nand2tetris-assembler
Compile the Java files:
javac src/*.java
To use the Hack Assembler, run the Main
class with the path to your Hack assembly file as an argument:
java src/Main path_to_input_file.asm path_to_output_file.hack
This will generate a .hack
file containing the translated Hack machine code. Note: the file extensions .asm
and .hack
are suggestions.
I want you to know that contributions are welcome. Please open an issue to discuss your ideas before making changes.
This project is licensed under the MIT License. Please take a look at the LICENSE.md file for details.