/hack-assembler

Assembler for the Hack assembly language https://www.nand2tetris.org/project06

Primary LanguageGoMIT LicenseMIT

Hack Assembler (nand2tetris)

Hi 😁 this is one of my learning projects, an assembler for the Hack assembly language. The language is defined in https://www.nand2tetris.org/project04. The assembler project itself is documented in https://www.nand2tetris.org/project06.

https://www.nand2tetris.org is an amazing course 🤩 !

Quickstart

To run the assembler once do

go run cmd/assembler/main.go testdata/Add.asm

otherwise build the above into a binary 😄 .

The machine code is written as text instead of binary as that is what was required in https://www.nand2tetris.org/project06.

Tests

I added ample tests written in Go for the parsing and translation logic. The machine code generated by this repos assembler is identical to the machine code generated by https://www.nand2tetris.org/project06 for the given sample programs. There might of course still be bugs. Please let me know if you find one 😅 .

Resources