summaryrefslogtreecommitdiff
path: root/projects
diff options
context:
space:
mode:
Diffstat (limited to 'projects')
-rw-r--r--projects/hack-vm/__main__.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/projects/hack-vm/__main__.py b/projects/hack-vm/__main__.py
index 5335583..b849edb 100644
--- a/projects/hack-vm/__main__.py
+++ b/projects/hack-vm/__main__.py
@@ -10,7 +10,7 @@ from .function import translate_function, translate_return
from .utils import *
-def vm_translate(input_path, verbose):
+def vm_translate(input_path, verbose, init):
# if input_path is a file, translate the file
# if it is a directory, translate every .vm file inside
try:
@@ -25,8 +25,7 @@ def vm_translate(input_path, verbose):
exit_on_error(f"Cannot open input path: {input_path}", EXIT_CODE_FILE_ERROR)
# assembly translated from all .vm files will be concatenated here
- asm = ""
- # asm = vminit(input_path.stem)
+ asm = vminit(input_path.stem) if init else ""
for input_fn in vm_files:
# load all vm commands from file, e.g. program/Main.vm
@@ -81,6 +80,7 @@ def vm_translate(input_path, verbose):
if __name__ == "__main__":
parser = ArgumentParser("hack-vm")
parser.add_argument("-v", "--verbose", action="store_true", help="verbose mode")
+ parser.add_argument("-I", "--no-init", action="store_true", help="do not write bootstrap code")
parser.add_argument("input_path", help="HACK VM file or directory")
args = parser.parse_args()
- vm_translate(Path(args.input_path), args.verbose)
+ vm_translate(Path(args.input_path), args.verbose, not args.no_init)