clean_notes.py 893 B

1234567891011121314151617181920212223242526272829303132
  1. import sys
  2. def trimmed(line,sep = ' '):
  3. s = [w for w in filter(lambda x: len(x) > 0,line.split(sep))]
  4. return s
  5. infile = open('notes.txt','r')
  6. for line in infile.readlines():
  7. instruction = ['x']*32
  8. trim = trimmed(line)
  9. for word in trim:
  10. if '..' in word:
  11. addrs = trimmed(word,'.')
  12. start = int(addrs[0])
  13. end = int(addrs[1][:addrs[1].find('=')])
  14. value = int(addrs[1][addrs[1].find('=')+1:],0)
  15. bitcount = start-end+1
  16. for i in range(end,start+1):
  17. instruction[i] = str(value & 1)
  18. value >>= 1
  19. itype = ''
  20. try:
  21. itype = line.split('0=3')[1]
  22. except:
  23. continue
  24. itype = trimmed(itype)[0]
  25. sys.stderr.write(itype+'\n')
  26. name = trim[0]
  27. while len(name) < 6:
  28. name += ' '
  29. print(name + ' '+''.join(reversed(instruction)))