1
0
mirror of https://github.com/jborza/emu6502.git synced 2024-11-22 14:32:27 +00:00
emu6502/bins/hex2bin.py

23 lines
448 B
Python
Raw Normal View History

2019-04-27 19:13:15 +00:00
import sys
output_name = sys.argv[1]
print(output_name)
f = open(output_name, 'wb')
def as_byte(value):
return bytes([value])
def process_line(line):
hexes = line[5:].strip()
hex_values = [int(hex,16) for hex in hexes.split(' ')]
for hex_value in hex_values:
print(as_byte(hex_value))
f.write(as_byte(hex_value))
#print(chr(hex_value), end = '')
for line in sys.stdin:
process_line(line)
f.close()