6502-sim/convert.py
2023-06-15 17:08:20 +00:00

20 lines
443 B
Python

import sys
stdout = sys.stdout.buffer
ix = 0
for line in sys.stdin:
words = line.split()
for word in words:
if ';' in word:
break
else:
if word == '??':
print(f'?? at {ix:02x}', file=sys.stderr)
number = 0xff
else:
number = int(word, 16)
assert number < 256
stdout.write(bytes([number]))
ix += 1;