Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3
  2.  
  3. import sys,os,fileinput
  4.  
  5.  
  6. def main(argv):
  7. for line in fileinput.input():
  8. bytes = line.lstrip(".byte ").rstrip('\n').split(',')
  9.  
  10. print(".byte ", end="")
  11.  
  12. for i,byte in enumerate(bytes):
  13. hexValue = int(byte.lstrip('$'),16)
  14. hexFormat = "${:02x}"
  15. print(hexFormat.format((hexValue<<2)&255), end="")
  16. if i != len(bytes) - 1:
  17. print(",",end="")
  18. print("");
  19.  
  20. if __name__ == "__main__":
  21. main(sys.argv[1:])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement