Skip to content

Instantly share code, notes, and snippets.

@jedie
Created September 30, 2013 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedie/6765945 to your computer and use it in GitHub Desktop.
Save jedie/6765945 to your computer and use it in GitHub Desktop.
from MC6809data.MC6809_data_raw import OP_DATA
OP_DICT = dict([(data["opcode"], data) for data in OP_DATA])
txt = """
170 DATA 34,12 ' Machine code for the
180 DATA 86,00 ' Screen filler program
190 DATA 8E,04,00 ' given below
200 DATA A7,80
210 DATA 8C,06,00
220 DATA 25,F9
230 DATA 4C
240 DATA 81,80
250 DATA 25,f1
260 DATA 35,92
"""
txt = txt.strip()
for line in txt.splitlines():
# print line
lineno, raw_code = line.split("DATA")
lineno = int(lineno)
raw_code = raw_code.split("'")[0]
raw_code = raw_code.strip()
code = [i.strip() for i in raw_code.split(",")]
# print code
opcode = int(code[0], 16)
print "%i DATA %-10s ' %s %s" % (
lineno,
raw_code,
OP_DICT[opcode]["mnemonic"],
" ".join(code[1:])
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment