Skip to content

Latest commit

 

History

History
43 lines (32 loc) · 1.82 KB

README.md

File metadata and controls

43 lines (32 loc) · 1.82 KB

Hack assembler

Build Status

This is a Ruby implementation of an assembler for the Hack machine language. The language itself is described in chapter four of “The Elements of Computing Systems”; this assembler conforms to the design described in chapter six.

Running

The assembler is at bin/assembler. It reads a symbolic assembly program from the file named in its first argument (or from standard input if no argument is provided); in slight defiance of the book, it then writes a binary version of that program to standard output rather than directly to a file.

For example:

$ git clone https://github.com/computationclub/hack-assembler
$ cd hack-assembler
$ ./bin/assembler spec/acceptance/examples/Max.asm
0000000000000000
1111110000010000
0000000000000001
1111010011010000
0000000000001010
1110001100000001
0000000000000001
1111110000010000
0000000000001100
1110101010000111
0000000000000000
1111110000010000
0000000000000010
1110001100001000
0000000000001110
1110101010000111

Testing

Both unit and acceptance tests are provided.

The unit tests verify that each module (Parser, Code and SymbolTable) implements the API described in chapter six. To run them, use bundle exec rspec spec/unit.

The acceptance tests run bin/assembler against each example Hack program and compare its output against that of the reference implementation. To run them, use bundle exec rspec spec/acceptance. This takes more time than running the unit tests.

To run all of the tests, use bundle exec rspec.