mixster

mixster

Sep 3rd, 2010
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. class opcode:
  4.   def __init__(self):
  5.     self.grp = []
  6.     for i in range(1, 4):
  7.       self.grp.append('')
  8.     self.prefix = ''
  9.     self.opcode = ''
  10.     self.suffix = ''
  11.     self.mnemon = ''
  12.     self.modiff = ''
  13.     self.def_f  = ''
  14.     self.f_vals = ''
  15.  
  16.   def print_format(self):
  17.     s = ','
  18.     return s.join([s.join(self.grp), self.prefix, self.opcode, self.suffix, self.mnemon, '`'*4, self.modiff, self.def_f, self.f_vals])
  19.  
  20. f = open('./opcodes', 'r')
  21. o = []
  22. h = -1
  23. c = 0
  24.  
  25. for line in f:
  26.   c += 1
  27.  
  28.   line = line.upper()
  29.  
  30.   if line.find('<TBODY') != -1:
  31.     o.append(opcode())
  32.     h += 1
  33.     c = 0
  34.     o[h].opcode = line[line.find('="') + 2:][:3]
  35.   elif line.find('COLSPAN') != -1:
  36.     c += int(line.split('"')[1])
  37.  
  38.  
  39.  
  40.   if c == 1:
  41.     o[h].prefix = line[line.find('>') + 1 : line.find('</TD>')]
  42.   elif c == 12:
  43.     o[h].mnemon = line[line.find('>') + 4 : line.find('</TD>')]
  44.   elif c in [18, 19, 20]:
  45.     o[h].grp[c - 18] = line[line.find('>') + 1 : line.find('</TD>')]
  46.   elif c == 22:
  47.     o[h].modiff = line[line.find('>') + 1 : line.find('</TD>')]
  48.   elif c == 23:
  49.     o[h].def_f  = line[line.find('>') + 1 : line.find('</TD>')]
  50.   elif c == 25:
  51.     o[h].f_vals = line[line.find('>') + 1 : line.find('</TD>')]
  52.  
  53. for t in o:
  54.   print t.print_format()
Add Comment
Please, Sign In to add comment