From b3ee892850d512f143822b78f7714951d25d064a Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Tue, 23 Aug 2022 23:41:29 +0800 Subject: hack-vm: init code --- projects/hack-vm/__main__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'projects/hack-vm/__main__.py') diff --git a/projects/hack-vm/__main__.py b/projects/hack-vm/__main__.py index bacbc94..5335583 100644 --- a/projects/hack-vm/__main__.py +++ b/projects/hack-vm/__main__.py @@ -1,6 +1,7 @@ import os from pathlib import Path from argparse import ArgumentParser +from .vminit import vminit from .memory import translate_memory from .arith_logic import translate_arith_logic from .compare import translate_compare @@ -25,6 +26,7 @@ def vm_translate(input_path, verbose): # assembly translated from all .vm files will be concatenated here asm = "" + # asm = vminit(input_path.stem) for input_fn in vm_files: # load all vm commands from file, e.g. program/Main.vm @@ -56,7 +58,7 @@ def vm_translate(input_path, verbose): case [("lt" | "eq" | "gt") as command]: asm += translate_compare(command, verbose) case [("label" | "goto" | "if-goto") as action, label]: - asm += translate_branching(action, label, verbose) + asm += translate_branching(action, label, prog, verbose) case [("call" | "function") as action, function, n]: asm += translate_function(action, function, n, prog, verbose) case ["return"]: -- cgit v1.2.3