1
0
mirror of https://github.com/jborza/emu6502.git synced 2024-11-24 12:30:48 +00:00
emu6502/bins/hex2bin.py
2019-04-27 21:13:15 +02:00

23 lines
448 B
Python

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()