Advertisement
GenesisFan64

AS_ARRAYFIX

Feb 10th, 2022
961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. # Array fixer for the AS' "too many arguments" error in some disassemblies
  2.  
  3. fin = open("rom_mars.lst", "rt",encoding='ascii', errors='ignore')
  4. fout = open("out.txt", "wt",encoding='ascii', errors='ignore')
  5. line_list = list()
  6.  
  7. # a5 replace
  8. for line in fin:
  9.     wrline = line
  10.  
  11.     a = "S2NA.asm"
  12.     if line.find(a) > 0:
  13.         a = "):"
  14.         if line.find(a) > 0:
  15.             a = line[13:].split(")")
  16.             a = a[0][1:]
  17.             line_list.append(a)
  18.  
  19. fin = open("S2NA.asm", "r",encoding='ascii', errors='ignore')
  20.  
  21. curr_num = 1
  22. curr_indx = 0
  23. for line in fin:
  24.     wrline = line
  25.  
  26.     c = int(line_list[curr_indx])
  27.     if curr_num == c:
  28.         print(c)
  29.         curr_indx += 1
  30.         a = line
  31.         b = a.find(":") # pick label
  32.         if b > 0:
  33.             c = line[:b]
  34.             fout.write(c+":"+"\n")  # write label
  35.             a = line[b+1:]
  36.         else:
  37.             a = a.replace("\t","")
  38.  
  39.  
  40.         e = a[:5].replace("\t","")
  41.         print(e)
  42.  
  43.         a = a[5:].replace("$","").split(",")
  44.         b = a[-1].find(";")
  45.         if b > 0:
  46.             b = a[-1][:b]
  47.             a[-1] = b.replace(" ","")
  48.  
  49.         # make new list
  50.         c = len(a)
  51.         d = 0
  52.         while c:
  53.             f = a[d].replace(" ","")
  54.             fout.write("\t\t"+e+" $"+f+"\n")
  55.             c -= 1
  56.             d += 1
  57.         #fout.write("\t\talign 2")
  58.     else:
  59.         fout.write(wrline)
  60.  
  61.     curr_num += 1
  62.  
  63. #numof_lines = len(line_list)
  64. #indx = 0
  65. #while numof_lines:
  66.  
  67.     #numof_lines -= 1
  68.     #indx += 1
  69.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement