def decode_assembly(tokens: List[str], labels: Dict[str, int]): destination_register = _parse_register(tokens[1]) _assert_left_arrow(tokens[2]) source_register = _parse_register(tokens[3]) number = int(tokens[4]) return AddRegisterAndNumber(number, source_register, destination_register)
def decode_assembly(tokens: List[str], labels: Dict[str, int]): destination_register = _parse_register(tokens[1]) _assert_left_arrow(tokens[2]) register_a = _parse_register(tokens[3]) register_b = _parse_register(tokens[4]) return Sub(register_a, register_b, destination_register)
def decode_assembly(tokens: List[str], labels: Dict[str, int]): instruction_index = _parse_jump_destination(tokens[1], labels) _assert_left_arrow(tokens[2]) register_a = _parse_register(tokens[3]) register_b = _parse_register(tokens[4]) return JumpIfGreaterThan(register_a, register_b, instruction_index)
def decode_assembly(tokens: List[str], labels: Dict[str, int]): register = _parse_register(tokens[1]) return PrintRegister(register)
def decode_assembly(tokens: List[str], labels: Dict[str, int]): register = _parse_register(tokens[1]) _assert_left_arrow(tokens[2]) value = int(tokens[3]) return Put(value, register)
def decode_assembly(tokens: List[str], labels: Dict[str, int]): register = _parse_register(tokens[1]) _assert_left_arrow(tokens[2]) address = _parse_memory_address(tokens[3]) return Load(register, address)
def decode_assembly(tokens: List[str], labels: Dict[str, int]): source_register = _parse_register(tokens[1]) _assert_right_arrow(tokens[2]) address = _parse_memory_address(tokens[3]) return Store(source_register, address)