"""Computer/zero Assembly emulator. Requires Python >= 3.7""" import re from typing import Dict from typing import Iterable from typing import List from typing import NamedTuple from typing import Optional from typing import Tuple NOP = 0b000 LDA = 0b001 STA = 0b010 ADD = 0b011 SUB = 0b100 BRZ = 0b101 JMP = 0b110 STP = 0b111 OPCODES = { "NOP": NOP, "LDA": LDA, "STA": STA, "ADD": ADD, "SUB": SUB, "BRZ": BRZ, "JMP": JMP, "STP": STP, } RE_INSTRUCTION = re.compile( r"\s*" r"(?:(?P