Example #1
0
    def _parse_instruction(self, line):
        ctl = line[0]
        lengths = []
        if line[1] == ';':
            inst_ctl = None
            start = None
            i = line.find(' ', 2)
            if i < 0:
                i = len(line.rstrip())
            comment_index = get_int_param(line[2:i])
        else:
            inst_ctl = line[1]
            if inst_ctl == 'I':
                i = find_unquoted(line.rstrip(), ' ', 2)
                address_end = j = find_unquoted(line, ';', 2, i)
            else:
                address_end = line.index(',', 2)
                i = find_unquoted(line.rstrip(), ' ', address_end + 1)
                j = find_unquoted(line, ';', address_end + 1, i)
            start = get_int_param(line[2:address_end])
            if j == i:
                comment_index = -1
            else:
                comment_index = get_int_param(line[j + 1:i])
            if j > address_end + 1:
                params = split_unquoted(line[address_end + 1:j], ',')
                lengths = parse_params(inst_ctl, params, 0)
            elif inst_ctl != 'I':
                raise ValueError

        comment = line[i:].strip()
        return ctl, inst_ctl, start, lengths, comment_index, comment
Example #2
0
    def _parse_instruction(self, line):
        ctl = line[0]
        lengths = []
        if line[1] == ';':
            inst_ctl = None
            start = None
            i = line.find(' ', 2)
            if i < 0:
                i = len(line.rstrip())
            comment_index = get_int_param(line[2:i])
        else:
            inst_ctl = line[1]
            if inst_ctl == 'I':
                i = find_unquoted(line.rstrip(), ' ', 2)
                address_end = j = find_unquoted(line, ';', 2, i)
            else:
                address_end = line.index(',', 2)
                i = find_unquoted(line.rstrip(), ' ', address_end + 1)
                j = find_unquoted(line, ';', address_end + 1, i)
            start = get_int_param(line[2:address_end])
            if j == i:
                comment_index = -1
            else:
                comment_index = get_int_param(line[j + 1:i])
            if j > address_end + 1:
                params = split_unquoted(line[address_end + 1:j], ',')
                lengths = parse_params(inst_ctl, params, 0)
            elif inst_ctl != 'I':
                raise ValueError

        comment = line[i:].strip()
        return ctl, inst_ctl, start, lengths, comment_index, comment
Example #3
0
 def _parse_instruction(self, line):
     ctl = line[0]
     try:
         address = get_int_param(line[1:6])
     except ValueError:
         raise SkoolParsingError("Invalid address ({}):\n{}".format(line[1:6], line.rstrip()))
     addr_str = self.address_fmt.format(address)
     comment_index = find_unquoted(line, ';', 6, neg=True)
     if comment_index > 0:
         end = comment_index
     else:
         end = len(line)
     operation = line[7:end].strip()
     comment = line[end + 1:].strip()
     return ControlLine(ctl, address, addr_str, operation, comment_index, comment, self.preserve_base)
Example #4
0
 def _parse_instruction(self, line):
     ctl = line[0]
     try:
         address = get_int_param(line[1:6])
     except ValueError:
         raise SkoolParsingError("Invalid address ({}):\n{}".format(
             line[1:6], line.rstrip()))
     addr_str = self.address_fmt.format(address)
     comment_index = find_unquoted(line, ';', 6, neg=True)
     if comment_index > 0:
         end = comment_index
     else:
         end = len(line)
     operation = line[7:end].strip()
     comment = line[end + 1:].strip()
     return ControlLine(ctl, address, addr_str, operation, comment_index,
                        comment, self.preserve_base)
Example #5
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))
Example #6
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))
Example #7
0
 def _set_bytes(self, line):
     address = parse_int(line[1:6])
     if address is not None:
         comment_index = find_unquoted(line, ';')
         operation = line[7:comment_index].strip()
         set_bytes(self.snapshot, address, operation)
Example #8
0
 def _set_bytes(self, line):
     address = parse_int(line[1:6])
     if address is not None:
         comment_index = find_unquoted(line, ';')
         operation = line[7:comment_index].strip()
         set_bytes(self.snapshot, address, operation)