https://github.com/mfl28/hackvmtranslator
A program that translates Hack virtual-machine language code (as defined in the nand2tetris course) into Hack assembly code.
https://github.com/mfl28/hackvmtranslator
cmake cpp17 hack-computer hack-vm-translator nand2tetris
Last synced: 3 months ago
JSON representation
A program that translates Hack virtual-machine language code (as defined in the nand2tetris course) into Hack assembly code.
- Host: GitHub
- URL: https://github.com/mfl28/hackvmtranslator
- Owner: mfl28
- License: mit
- Created: 2019-05-03T17:50:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-29T17:43:44.000Z (over 5 years ago)
- Last Synced: 2025-03-15T04:42:29.290Z (10 months ago)
- Topics: cmake, cpp17, hack-computer, hack-vm-translator, nand2tetris
- Language: C++
- Homepage:
- Size: 26.4 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HackVMTranslator
[](https://dev.azure.com/mfl28/HackVMTranslator/_build/latest?definitionId=4&branchName=master)
[](https://lgtm.com/projects/g/mfl28/HackVMTranslator/context:cpp)
| OS | Build & Test Pipeline Status |
| ------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
| Linux |[](https://dev.azure.com/mfl28/HackVMTranslator/_build/latest?definitionId=4&branchName=master) |
| MacOS |[](https://dev.azure.com/mfl28/HackVMTranslator/_build/latest?definitionId=4&branchName=master) |
| Windows |[](https://dev.azure.com/mfl28/HackVMTranslator/_build/latest?definitionId=4&branchName=master) |
This is a C++-implementation of a translator for the Hack-platform's virtual-machine language as defined in [project 7](https://www.nand2tetris.org/project07) and [project 8](https://www.nand2tetris.org/project08) of the nand2tetris-course.
The program takes as argument either a single `.vm`-file or a directory containing such files, translates them into Hack assembly-language code and writes this code into a single `.asm`-file.
## Building the program
_Note_: To build this program, a compiler that supports C++17 and `std::filesystem` is required (e.g. gcc version ≥ 8).
```bash
git clone https://github.com/mfl28/HackVMTranslator.git
cd HackVMTranslator
cmake -B build # Use option "-D BUILD_TESTING=OFF" if you do not want to build the unit-tests.
cmake --build build
```
## Running the program
After you built the program, do the following from within the `build`-directory:
#### Linux
```bash
./HackVMTranslator path/to/filename.vm # Or "./HackVMTranslator path/to/directory"
```
#### Windows
```bash
cd Debug # Or "cd Release" if you built using Release-configuration.
.\HackVMTranslator.exe path\to\filename.vm # Or ".\HackVMTranslator path\to\directory"
```
## Running the tests
If you built the program including the unit-tests, then these can be run from within the `build`-directory by doing the following:
#### Linux
```bash
ctest -V
```
#### Windows
```bash
ctest -C Debug -V # Or "ctest -C Release -V" if you built using Release-configuration.
```
## References
- [nand2tetris-course](https://www.nand2tetris.org)
- [Google Test](https://github.com/google/googletest)