Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- class opcode:
- def __init__(self):
- self.grp = []
- for i in range(1, 4):
- self.grp.append('')
- self.prefix = ''
- self.opcode = ''
- self.suffix = ''
- self.mnemon = ''
- self.modiff = ''
- self.def_f = ''
- self.f_vals = ''
- def print_format(self):
- s = ','
- return s.join([s.join(self.grp), self.prefix, self.opcode, self.suffix, self.mnemon, '`'*4, self.modiff, self.def_f, self.f_vals])
- f = open('./opcodes', 'r')
- o = []
- h = -1
- c = 0
- for line in f:
- c += 1
- line = line.upper()
- if line.find('<TBODY') != -1:
- o.append(opcode())
- h += 1
- c = 0
- o[h].opcode = line[line.find('="') + 2:][:3]
- elif line.find('COLSPAN') != -1:
- c += int(line.split('"')[1])
- if c == 1:
- o[h].prefix = line[line.find('>') + 1 : line.find('</TD>')]
- elif c == 12:
- o[h].mnemon = line[line.find('>') + 4 : line.find('</TD>')]
- elif c in [18, 19, 20]:
- o[h].grp[c - 18] = line[line.find('>') + 1 : line.find('</TD>')]
- elif c == 22:
- o[h].modiff = line[line.find('>') + 1 : line.find('</TD>')]
- elif c == 23:
- o[h].def_f = line[line.find('>') + 1 : line.find('</TD>')]
- elif c == 25:
- o[h].f_vals = line[line.find('>') + 1 : line.find('</TD>')]
- for t in o:
- print t.print_format()
Add Comment
Please, Sign In to add comment