From 51c8325661eab4667a11431175f12eb6a08cc36a Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Mon, 22 Aug 2022 17:24:46 +0800 Subject: hack-vm: branching --- projects/hack-vm/__main__.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'projects/hack-vm/__main__.py') diff --git a/projects/hack-vm/__main__.py b/projects/hack-vm/__main__.py index a1dce1f..5373fe9 100644 --- a/projects/hack-vm/__main__.py +++ b/projects/hack-vm/__main__.py @@ -2,6 +2,7 @@ from argparse import ArgumentParser from .memory import translate_memory from .arith_logic import translate_arith_logic from .compare import translate_compare +from .branching import translate_branching from .utils import * @@ -38,6 +39,8 @@ def vm_translate(input_path): asm += translate_arith_logic(command) case [("lt" | "eq" | "gt") as command]: asm += translate_compare(command) + case [("label" | "goto" | "if-goto") as action, label]: + asm += translate_branching(action, label) case _: exit_on_error( f"Syntax error: invalid command: {cmd}", EXIT_CODE_SYNTAX_ERROR -- cgit v1.2.3