Collin J. Doering
During the firstpass, strip spaces from: - between the instruction destination and '=' - between '=' and the instruction ALU ops - between the instruction ALU ops and ';' - between ';' and the instruction jump Signed-off-by: Collin J. Doering <firstname.lastname@example.org>
|4 years ago|
|doc/examples||5 years ago|
|src||4 years ago|
|testsuite||5 years ago|
|.gitignore||5 years ago|
|Asmblr.cabal||5 years ago|
|LICENSE||5 years ago|
|README.md||4 years ago|
|Setup.hs||5 years ago|
Asmblr is a small Haskell program that transforms Hack Assembly into its machine language
representation. The parser itself is made available though the library
hackasm and can be
included in other projects. To see its documentation run
cabal haddock and view the
Asmblr requires GHC and cabal to be built and can be done like so:
$ cabal configure $ cabal build
Once built, the
Asmblr executable will be in the
dist/build/Asmblr folder, and can be run
using you shell or cabal (via the command
cabal run Asmblr). The
Asmblr program can also be
cabal install. For more information on installing cabal packages and using
cabal see its manual.
This project comes with the directory
doc/examples that contains example Hack Assembly
programs used for testing the assembler. To clarify how to run the
Asmblr binary once built
we will use of of the aforementioned Hack Assembly files as an input, in this case
Asmblr using cabal:
$ cabal run Asmblr -- doc/examples/Pong.asm
Asmblr using POSIX shell:
$ ./dist/build/Asmblr/Asmblr doc/examples/Pong.asm
Both of the previous commands invoke the
Asmblr on the file
generate a file
Pong.hack in the current directory.
Asmblr also supports taking input from
stdin as well as writing its output to
stdout or an arbitrary file given by the user. For
convenience the output of
Asmblr --help is provided below.
Usage: Asmblr [OPTION...] file -v --verbose chatty output on stderr -V --version show version number -h --help show program usage -o[FILE] --output[=FILE] output file or '-' for stdout
The creation of this software was made possible by the following open source tools and libraries.
There are some minor issues that can be cleaned up in future releases. Namely, making error output more human readable, and a few minor optimization's.
(<?> "error description")throughout parsers to make error output more readable
If you discover a bug or have an issue with this project, please file a bug using the Rekahsoft flyspray powered bug tracker.
The Hack Machine Code generated by this assembler is only useful if a Hack machine or simulator is available. One such simulator is available with the Nand to Tetris course. Alternatively, I've written a VHDL implementation of the Hack Platform which can be used to simulate the Hack Machine in order to run the assembly generated by this assembler. Currently it is not as full featured and user friendly as the simulator given by the Nand to Tetris course, and likely never will be as it's end goal is to be implemented on a FPGA with verification of the design done via simulation. For more details see its README.