Пример #1
0
 def _parse_instruction(self, line, removed):
     try:
         address = get_int_param(line[1:6])
     except ValueError:
         raise SkoolParsingError("Invalid address ({}):\n{}".format(
             line[1:6], line.rstrip()))
     original_op = partition_unquoted(line[6:], ';')[0].strip()
     subbed = max(self.subs)
     if subbed:
         operations = [
             partition_unquoted(s, ';') for s in self.subs[subbed]
         ]
     else:
         operations = [(original_op, '', '')]
     self.subs = defaultdict(list, {0: []})
     for op, sep, comment in operations:
         operation = op.strip() or original_op
         if operation:
             data = assemble(operation, address)
             if data:
                 end_address = address + len(data)
                 if address not in removed:
                     self.snapshot[address:end_address] = data
                     self.base_address = min(self.base_address, address)
                     self.end_address = max(self.end_address, end_address)
                 if subbed:
                     removed.update(range(address, end_address))
                 address = end_address
             else:
                 warn("Failed to assemble:\n {} {}".format(
                     address, operation))
                 break
         original_op = None
Пример #2
0
 def _parse_instruction(self, line):
     try:
         address = get_int_param(line[1:6])
     except ValueError:
         raise SkoolParsingError("Invalid address ({}):\n{}".format(line[1:6], line.rstrip()))
     for sub in self.subs:
         if sub is not None:
             operation = sub
             self.subs = [None] * 4
             break
     else:
         comment_index = find_unquoted(line, ';', 6)
         operation = line[7:comment_index].strip()
     data = assemble(operation, address)
     if data:
         end_address = address + len(data)
         self.snapshot[address:end_address] = data
         self.base_address = min(self.base_address, address)
         self.end_address = max(self.end_address, end_address)
     else:
         warn("Failed to assemble:\n {} {}".format(address, operation))
Пример #3
0
 def _parse_instruction(self, line):
     try:
         address = get_int_param(line[1:6])
     except ValueError:
         raise SkoolParsingError("Invalid address ({}):\n{}".format(line[1:6], line.rstrip()))
     for sub in self.subs:
         if sub is not None:
             operation = sub
             self.subs = [None] * 4
             break
     else:
         comment_index = find_unquoted(line, ';', 6)
         operation = line[7:comment_index].strip()
     data = assemble(operation, address)
     if data:
         end_address = address + len(data)
         self.snapshot[address:end_address] = data
         self.base_address = min(self.base_address, address)
         self.end_address = max(self.end_address, end_address)
     else:
         warn("Failed to assemble:\n {} {}".format(address, operation))
Пример #4
0
def set_bytes(snapshot, address, operation):
    data = assemble(operation, address)
    snapshot[address:address + len(data)] = data
Пример #5
0
 def _test_operation(self, operation, exp_data, address):
     data = assemble(operation, address)
     self.assertEqual(exp_data, data, "assemble('{}', {}) failed".format(operation, address))
     exp_length = len(data)
     length = get_size(operation, address)
     self.assertEqual(exp_length, length, "get_size('{}', {}) failed".format(operation, address))
Пример #6
0
def set_bytes(snapshot, address, operation):
    data = assemble(operation, address)
    snapshot[address:address + len(data)] = data