Skip to content

Latest commit

 

History

History
42 lines (31 loc) · 1.17 KB

File metadata and controls

42 lines (31 loc) · 1.17 KB

hackasm

An assembler for the Hack assemble language from the Nand2Tetris coursera course.

Relevant course: project 6

Notes on the assembler:

  • Is a 3 pass assembler
    • 1 pass to build symbol table for loops
    • 1 pass to build symbol table for addresses
    • 1 pass to convert instructions into the internal haskell representation
  • The assembler makes use of the attoparsec applicative parser combinator in the parsing stage
  • It uses binary library in to spit out the binary data for the assembler
  • By default the assembler spits out a string of 1s and 0s to create the correctly formatted strings for the project

Instructions

Assumes the reader has stack installed on their system.

Build the program with:

stack build

To view intermediate representation

stack exec hackasm analyse <input>

To assemble actual files:

stack exec hackasm <input> <output>

To generate a binary file instead of a bunch of strings:

stack exec hackasm --binary <input> <output>