A Hack assembler in OCaml. A program that translates assembly code for the Hack computer into its binary representation.
This is project 6 of the Nand to Tetris course.
To run the program, run the following
dune exec -- ./assembler.exe <filename>.asmwhere <filename>.asm is the assembly file you wish to translate. The file <filename>.hack should be created.
To run the tests, run
dune runtestThe parsing library menhir, and the lexing library ocamllex, are used to extract the A-instructions, C-instructions, and Labels. It's probably overkill, but it was quite simple to setup after following chapter 10 of this book about functional programming in OCaml.
opam install base core menhir stdio