Guest User

post-LLVM

a guest
Apr 6th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import sys
  2. file = open(sys.argv[1])
  3.  
  4. import sys
  5. file = open(sys.argv[1])
  6. out = open(sys.argv[2], "w")
  7. result = """:init
  8.  SET C, SP
  9.  SUB C, 256
  10. """
  11.    
  12. for line in file.readlines():
  13.     try:
  14.         for symbol in ["file", "text", "globl", "align", "type", "size"]:
  15.             if line.strip().find("."+symbol) == 0:
  16.                 raise Error
  17.     except:
  18.         continue
  19.     if len(line.split()) and line.strip()[0] != ";":
  20.         if line.split()[0][-1] == ":":
  21.             line =  " ".join([":"+line.split(" ")[0][:-1]]  + line.split(" ")[1:])
  22.     result = result + line
  23.    
  24. result = result + """
  25. :break
  26.  BRK
  27.  
  28. :crash
  29.  SET PC, crash
  30. """
  31. print result
  32. out.write(result)
Advertisement
Add Comment
Please, Sign In to add comment