Esempio n. 1
0
    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)
Esempio n. 2
0
 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)
Esempio n. 4
0
 def decode_assembly(tokens: List[str], labels: Dict[str, int]):
     register = _parse_register(tokens[1])
     return PrintRegister(register)
Esempio n. 5
0
 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)
Esempio n. 6
0
 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)
Esempio n. 7
0
 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)