Merge pull request #19 from gardners/master

Add support for 4502/4510 CPU from Commodore 65
This commit is contained in:
Michael C. Martin 2014-03-22 22:02:56 -07:00
commit 88c7214950
11 changed files with 1048 additions and 359 deletions

9
README
View File

@ -1,8 +1,9 @@
Ophis is a cross-assembler for the 65xx series of chips. It supports
the stock 6502 opcodes, the 65c02 extensions, and syntax for the
"undocumented opcodes" in the 6510 chip used on the Commodore
the stock 6502 opcodes, the 65c02 extensions, experimental support
for the 4502/4510 used in the Commodore 65 prototypes, and syntax for
the "undocumented opcodes" in the 6510 chip used on the Commodore
64. (Syntax for these opcodes matches those given in the VICE team's
documentation.)
documentation.)
Ophis is written in pure Python and should be highly portable.
@ -10,7 +11,7 @@ It is provided under the MIT license, reproduced below:
---
Ophis, Copyright (C) 2002-2012 Michael Martin and contributors
Ophis, Copyright (C) 2002-2014 Michael Martin and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -26,7 +26,7 @@ listfile = None
def parse_args(raw_args):
"Populate the module's globals based on the command-line options given."
global enable_collapse, enable_branch_extend
global enable_undoc_ops, enable_65c02_exts
global enable_undoc_ops, enable_65c02_exts, enable_4502_exts
global warn_on_branch_extend
global print_summary, print_loaded_files
global print_pass, print_ir, print_labels
@ -46,6 +46,8 @@ def parse_args(raw_args):
help="Enable 6502 undocumented opcodes")
ingrp.add_option("-c", "--65c02", action="store_true", default=False,
dest="c02", help="Enable 65c02 extended instruction set")
ingrp.add_option("-4", "--4502", action="store_true", default=False,
dest="csg4502", help="Enable 4502 extended instruction set")
outgrp = optparse.OptionGroup(parser, "Console output options")
outgrp.add_option("-v", "--verbose", action="store_const", const=2,
@ -72,6 +74,10 @@ def parse_args(raw_args):
parser.error("No input files specified")
if options.c02 and options.undoc:
parser.error("--undoc and --65c02 are mutually exclusive")
if options.c02 and options.csg4502:
parser.error("--undoc and --65c02 are mutually exclusive")
if options.csg4502 and options.undoc:
parser.error("--undoc and --65c02 are mutually exclusive")
infiles = args
outfile = options.outfile
@ -79,6 +85,7 @@ def parse_args(raw_args):
enable_branch_extend = options.enable_branch_extend
enable_undoc_ops = options.undoc
enable_65c02_exts = options.c02
enable_4502_exts = options.csg4502
warn_on_branch_extend = options.warn
print_summary = options.verbose > 0 # no options set
print_loaded_files = options.verbose > 1 # v

View File

@ -104,6 +104,10 @@ def lex(point, line):
result.append(Lexeme("X"))
elif id == "y":
result.append(Lexeme("Y"))
elif id == "z":
result.append(Lexeme("Z"))
elif id == "sp":
result.append(Lexeme("SP"))
else:
result.append(Lexeme("LABEL", id))
return
@ -187,7 +191,7 @@ class ParseLine(object):
if token.type in tokens:
return token
if 'LABEL' in tokens:
if token.type in ['X', 'Y']:
if token.type in ['X', 'Y', 'Z', 'SP']:
token.value = token.type.lower()
token.type = 'LABEL'
return token
@ -210,7 +214,7 @@ def parse_expr(line):
next = line.lookahead(0).type
if next == "NUM":
return IR.ConstantExpr(line.expect("NUM").value)
elif next in ["LABEL", "X", "Y", "OPCODE"]:
elif next in ["LABEL", "X", "Y", "Z", "SP", "OPCODE"]:
return IR.LabelExpr(line.expect("LABEL").value)
elif next == "^":
line.expect("^")
@ -324,20 +328,33 @@ def parse_line(ppt, lexemelist):
line.expect("(")
arg = parse_expr(line)
if line.lookahead(0).type == ",":
mode = "PointerX"
line.expect(",")
line.expect("X")
line.expect(")")
line.expect("EOL")
if line.lookahead(0).type == "X":
mode = "PointerX"
line.expect("X")
line.expect(")")
line.expect("EOL")
else:
mode = "PointerSPY"
line.expect("SP")
line.expect(")")
line.expect(",")
line.expect("Y")
line.expect("EOL")
else:
line.expect(")")
tok = line.expect(",", "EOL").type
if tok == "EOL":
mode = "Pointer"
else:
mode = "PointerY"
line.expect("Y")
line.expect("EOL")
if line.lookahead(0).type == "Y":
mode = "PointerY"
line.expect("Y")
line.expect("EOL")
else:
mode = "PointerZ"
line.expect("Z")
line.expect("EOL")
elif line.lookahead(0).type == "EOL":
mode = "Implied"
arg = None
@ -351,11 +368,13 @@ def parse_line(ppt, lexemelist):
arg2 = parse_expr(line)
mode = "Memory2"
else:
tok = line.expect("X", "Y").type
tok = line.expect("X", "Y", "Z").type
if tok == "X":
mode = "MemoryX"
else:
elif tok == "Y":
mode = "MemoryY"
else:
mode = "MemoryZ"
line.expect("EOL")
else:
mode = "Memory"

View File

@ -104,6 +104,8 @@ def run_ophis(args):
Ophis.Opcodes.opcodes.update(Ophis.Opcodes.undocops)
elif Ophis.CmdLine.enable_65c02_exts:
Ophis.Opcodes.opcodes.update(Ophis.Opcodes.c02extensions)
elif Ophis.CmdLine.enable_4502_exts:
Ophis.Opcodes.opcodes.update(Ophis.Opcodes.csg4502extensions)
Ophis.CorePragmas.reset()
return run_all()

View File

@ -12,340 +12,525 @@
# the tables in tools/opcodes. Edit those tables, not these.
# Names of addressing modes
modes = ["Implied", # 0
"Immediate", # 1
"Zero Page", # 2
"Zero Page, X", # 3
"Zero Page, Y", # 4
"Absolute", # 5
"Absolute, X", # 6
"Absolute, Y", # 7
"(Absolute)", # 8
"(Absolute, X)", # 9
"(Absolute), Y", # 10
"(Zero Page)", # 11
"(Zero Page, X)", # 12
"(Zero Page), Y", # 13
"Relative", # 14
"Zero Page, Relative"] # 15
modes = ["Implied",
"Immediate",
"ImmediateLong",
"Zero Page",
"Zero Page, X",
"Zero Page, Y",
"Absolute",
"Absolute, X",
"Absolute, Y",
"(Absolute)",
"(Absolute, X)",
"(Absolute), Y",
"(Absolute), Z",
"(Zero Page)",
"(Zero Page, X)",
"(Zero Page), Y",
"(Zero Page, SP), Y",
"(Zero Page), Z",
"Relative",
"RelativeLong",
"Zero Page, Relative"]
# Lengths of the argument
lengths = [0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2]
lengths = [0, 1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2]
opcodes = {
'adc': [None, 0x69, 0x65, 0x75, None, 0x6D, 0x7D, 0x79,
None, None, None, None, 0x61, 0x71, None, None],
'adc.w': [None, None, None, None, None, 0x6D, 0x7D, 0x79,
None, None, None, None, None, None, None, None],
'and': [None, 0x29, 0x25, 0x35, None, 0x2D, 0x3D, 0x39,
None, None, None, None, 0x21, 0x31, None, None],
'and.w': [None, None, None, None, None, 0x2D, 0x3D, 0x39,
None, None, None, None, None, None, None, None],
'asl': [0x0A, None, 0x06, 0x16, None, 0x0E, 0x1E, None,
None, None, None, None, None, None, None, None],
'asl.w': [None, None, None, None, None, 0x0E, 0x1E, None,
None, None, None, None, None, None, None, None],
'adc': [None, 0x69, None, 0x65, 0x75, None, 0x6D, 0x7D,
0x79, None, None, None, None, None, 0x61, 0x71, None, None, None, None, None],
'adc.w': [None, None, None, None, None, None, 0x6D, 0x7D,
0x79, None, None, None, None, None, None, None, None, None, None, None, None],
'and': [None, 0x29, None, 0x25, 0x35, None, 0x2D, 0x3D,
0x39, None, None, None, None, None, 0x21, 0x31, None, None, None, None, None],
'and.w': [None, None, None, None, None, None, 0x2D, 0x3D,
0x39, None, None, None, None, None, None, None, None, None, None, None, None],
'asl': [0x0A, None, None, 0x06, 0x16, None, 0x0E, 0x1E,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'asl.w': [None, None, None, None, None, None, 0x0E, 0x1E,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'bcc': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, 0x90, None],
None, None, None, None, None, None, None, None, None, None, 0x90, None, None],
'bcs': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, 0xB0, None],
None, None, None, None, None, None, None, None, None, None, 0xB0, None, None],
'beq': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, 0xF0, None],
'bit': [None, None, 0x24, None, None, 0x2C, None, None,
None, None, None, None, None, None, None, None],
'bit.w': [None, None, None, None, None, 0x2C, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, 0xF0, None, None],
'bit': [None, None, None, 0x24, None, None, 0x2C, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'bit.w': [None, None, None, None, None, None, 0x2C, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'bmi': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, 0x30, None],
None, None, None, None, None, None, None, None, None, None, 0x30, None, None],
'bne': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, 0xD0, None],
None, None, None, None, None, None, None, None, None, None, 0xD0, None, None],
'bpl': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, 0x10, None],
None, None, None, None, None, None, None, None, None, None, 0x10, None, None],
'brk': [0x00, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'bvc': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, 0x50, None],
None, None, None, None, None, None, None, None, None, None, 0x50, None, None],
'bvs': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, 0x70, None],
None, None, None, None, None, None, None, None, None, None, 0x70, None, None],
'clc': [0x18, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'cld': [0xD8, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'cli': [0x58, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'clv': [0xB8, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'cmp': [None, 0xC9, 0xC5, 0xD5, None, 0xCD, 0xDD, 0xD9,
None, None, None, None, 0xC1, 0xD1, None, None],
'cmp.w': [None, None, None, None, None, 0xCD, 0xDD, 0xD9,
None, None, None, None, None, None, None, None],
'cpx': [None, 0xE0, 0xE4, None, None, 0xEC, None, None,
None, None, None, None, None, None, None, None],
'cpx.w': [None, None, None, None, None, 0xEC, None, None,
None, None, None, None, None, None, None, None],
'cpy': [None, 0xC0, 0xC4, None, None, 0xCC, None, None,
None, None, None, None, None, None, None, None],
'cpy.w': [None, None, None, None, None, 0xCC, None, None,
None, None, None, None, None, None, None, None],
'dec': [None, None, 0xC6, 0xD6, None, 0xCE, 0xDE, None,
None, None, None, None, None, None, None, None],
'dec.w': [None, None, None, None, None, 0xCE, 0xDE, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'cmp': [None, 0xC9, None, 0xC5, 0xD5, None, 0xCD, 0xDD,
0xD9, None, None, None, None, None, 0xC1, 0xD1, None, None, None, None, None],
'cmp.w': [None, None, None, None, None, None, 0xCD, 0xDD,
0xD9, None, None, None, None, None, None, None, None, None, None, None, None],
'cpx': [None, 0xE0, None, 0xE4, None, None, 0xEC, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'cpx.w': [None, None, None, None, None, None, 0xEC, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'cpy': [None, 0xC0, None, 0xC4, None, None, 0xCC, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'cpy.w': [None, None, None, None, None, None, 0xCC, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'dec': [None, None, None, 0xC6, 0xD6, None, 0xCE, 0xDE,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'dec.w': [None, None, None, None, None, None, 0xCE, 0xDE,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'dex': [0xCA, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'dey': [0x88, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'eor': [None, 0x49, 0x45, 0x55, None, 0x4D, 0x5D, 0x59,
None, None, None, None, 0x41, 0x51, None, None],
'eor.w': [None, None, None, None, None, 0x4D, 0x5D, 0x59,
None, None, None, None, None, None, None, None],
'inc': [None, None, 0xE6, 0xF6, None, 0xEE, 0xFE, None,
None, None, None, None, None, None, None, None],
'inc.w': [None, None, None, None, None, 0xEE, 0xFE, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'eor': [None, 0x49, None, 0x45, 0x55, None, 0x4D, 0x5D,
0x59, None, None, None, None, None, 0x41, 0x51, None, None, None, None, None],
'eor.w': [None, None, None, None, None, None, 0x4D, 0x5D,
0x59, None, None, None, None, None, None, None, None, None, None, None, None],
'inc': [None, None, None, 0xE6, 0xF6, None, 0xEE, 0xFE,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'inc.w': [None, None, None, None, None, None, 0xEE, 0xFE,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'inx': [0xE8, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'iny': [0xC8, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'jmp': [None, None, None, None, None, 0x4C, None, None,
0x6C, None, None, None, None, None, None, None],
'jsr': [None, None, None, None, None, 0x20, None, None,
None, None, None, None, None, None, None, None],
'lda': [None, 0xA9, 0xA5, 0xB5, None, 0xAD, 0xBD, 0xB9,
None, None, None, None, 0xA1, 0xB1, None, None],
'lda.w': [None, None, None, None, None, 0xAD, 0xBD, 0xB9,
None, None, None, None, None, None, None, None],
'ldx': [None, 0xA2, 0xA6, None, 0xB6, 0xAE, None, 0xBE,
None, None, None, None, None, None, None, None],
'ldx.w': [None, None, None, None, None, 0xAE, None, 0xBE,
None, None, None, None, None, None, None, None],
'ldy': [None, 0xA0, 0xA4, 0xB4, None, 0xAC, 0xBC, None,
None, None, None, None, None, None, None, None],
'ldy.w': [None, None, None, None, None, 0xAC, 0xBC, None,
None, None, None, None, None, None, None, None],
'lsr': [0x4A, None, 0x46, 0x56, None, 0x4E, 0x5E, None,
None, None, None, None, None, None, None, None],
'lsr.w': [None, None, None, None, None, 0x4E, 0x5E, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'jmp': [None, None, None, None, None, None, 0x4C, None,
None, 0x6C, None, None, None, None, None, None, None, None, None, None, None],
'jsr': [None, None, None, None, None, None, 0x20, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'lda': [None, 0xA9, None, 0xA5, 0xB5, None, 0xAD, 0xBD,
0xB9, None, None, None, None, None, 0xA1, 0xB1, None, None, None, None, None],
'lda.w': [None, None, None, None, None, None, 0xAD, 0xBD,
0xB9, None, None, None, None, None, None, None, None, None, None, None, None],
'ldx': [None, 0xA2, None, 0xA6, None, 0xB6, 0xAE, None,
0xBE, None, None, None, None, None, None, None, None, None, None, None, None],
'ldx.w': [None, None, None, None, None, None, 0xAE, None,
0xBE, None, None, None, None, None, None, None, None, None, None, None, None],
'ldy': [None, 0xA0, None, 0xA4, 0xB4, None, 0xAC, 0xBC,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'ldy.w': [None, None, None, None, None, None, 0xAC, 0xBC,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'lsr': [0x4A, None, None, 0x46, 0x56, None, 0x4E, 0x5E,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'lsr.w': [None, None, None, None, None, None, 0x4E, 0x5E,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'nop': [0xEA, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'ora': [None, 0x09, 0x05, 0x15, None, 0x0D, 0x1D, 0x19,
None, None, None, None, 0x01, 0x11, None, None],
'ora.w': [None, None, None, None, None, 0x0D, 0x1D, 0x19,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'ora': [None, 0x09, None, 0x05, 0x15, None, 0x0D, 0x1D,
0x19, None, None, None, None, None, 0x01, 0x11, None, None, None, None, None],
'ora.w': [None, None, None, None, None, None, 0x0D, 0x1D,
0x19, None, None, None, None, None, None, None, None, None, None, None, None],
'pha': [0x48, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'php': [0x08, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'pla': [0x68, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'plp': [0x28, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'rol': [0x2A, None, 0x26, 0x36, None, 0x2E, 0x3E, None,
None, None, None, None, None, None, None, None],
'rol.w': [None, None, None, None, None, 0x2E, 0x3E, None,
None, None, None, None, None, None, None, None],
'ror': [0x6A, None, 0x66, 0x76, None, 0x6E, 0x7E, None,
None, None, None, None, None, None, None, None],
'ror.w': [None, None, None, None, None, 0x6E, 0x7E, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rol': [0x2A, None, None, 0x26, 0x36, None, 0x2E, 0x3E,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rol.w': [None, None, None, None, None, None, 0x2E, 0x3E,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'ror': [0x6A, None, None, 0x66, 0x76, None, 0x6E, 0x7E,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'ror.w': [None, None, None, None, None, None, 0x6E, 0x7E,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rti': [0x40, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rts': [0x60, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'sbc': [None, 0xE9, 0xE5, 0xF5, None, 0xED, 0xFD, 0xF9,
None, None, None, None, 0xE1, 0xF1, None, None],
'sbc.w': [None, None, None, None, None, 0xED, 0xFD, 0xF9,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'sbc': [None, 0xE9, None, 0xE5, 0xF5, None, 0xED, 0xFD,
0xF9, None, None, None, None, None, 0xE1, 0xF1, None, None, None, None, None],
'sbc.w': [None, None, None, None, None, None, 0xED, 0xFD,
0xF9, None, None, None, None, None, None, None, None, None, None, None, None],
'sec': [0x38, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'sed': [0xF8, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'sei': [0x78, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'sta': [None, None, 0x85, 0x95, None, 0x8D, 0x9D, 0x99,
None, None, None, None, 0x81, 0x91, None, None],
'sta.w': [None, None, None, None, None, 0x8D, 0x9D, 0x99,
None, None, None, None, None, None, None, None],
'stx': [None, None, 0x86, None, 0x96, 0x8E, None, None,
None, None, None, None, None, None, None, None],
'stx.w': [None, None, None, None, None, 0x8E, None, None,
None, None, None, None, None, None, None, None],
'sty': [None, None, 0x84, 0x94, None, 0x8C, None, None,
None, None, None, None, None, None, None, None],
'sty.w': [None, None, None, None, None, 0x8C, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'sta': [None, None, None, 0x85, 0x95, None, 0x8D, 0x9D,
0x99, None, None, None, None, None, 0x81, 0x91, None, None, None, None, None],
'sta.w': [None, None, None, None, None, None, 0x8D, 0x9D,
0x99, None, None, None, None, None, None, None, None, None, None, None, None],
'stx': [None, None, None, 0x86, None, 0x96, 0x8E, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'stx.w': [None, None, None, None, None, None, 0x8E, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'sty': [None, None, None, 0x84, 0x94, None, 0x8C, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'sty.w': [None, None, None, None, None, None, 0x8C, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'tax': [0xAA, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'tay': [0xA8, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'tsx': [0xBA, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'txa': [0x8A, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'txs': [0x9A, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'tya': [0x98, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
}
undocops = {
'anc': [None, 0x0B, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'ane': [None, 0x8B, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'arr': [None, 0x6B, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'asr': [None, 0x4B, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'dcp': [None, None, 0xC7, 0xD7, None, 0xCF, 0xDF, 0xDB,
None, None, None, None, 0xC3, 0xD3, None, None],
'isb': [None, None, 0xE7, 0xF7, None, 0xEF, 0xFF, 0xFB,
None, None, None, None, 0xE3, 0xF3, None, None],
'las': [None, None, None, None, None, None, None, 0xBB,
None, None, None, None, None, None, None, None],
'lax': [None, None, 0xA7, None, 0xB7, 0xAF, None, 0xBF,
None, None, None, None, 0xA3, 0xB3, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'dcp': [None, None, None, 0xC7, 0xD7, None, 0xCF, 0xDF,
0xDB, None, None, None, None, None, 0xC3, 0xD3, None, None, None, None, None],
'isb': [None, None, None, 0xE7, 0xF7, None, 0xEF, 0xFF,
0xFB, None, None, None, None, None, 0xE3, 0xF3, None, None, None, None, None],
'las': [None, None, None, None, None, None, None, None,
0xBB, None, None, None, None, None, None, None, None, None, None, None, None],
'lax': [None, None, None, 0xA7, None, 0xB7, 0xAF, None,
0xBF, None, None, None, None, None, 0xA3, 0xB3, None, None, None, None, None],
'lxa': [None, 0xAB, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'nop': [0xEA, None, 0x04, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'rla': [None, None, 0x27, 0x37, None, 0x2F, 0x3F, 0x3B,
None, None, None, None, 0x23, 0x33, None, None],
'rra': [None, None, 0x67, 0x77, None, 0x6F, 0x7F, 0x7B,
None, None, None, None, 0x63, 0x73, None, None],
'sax': [None, None, 0x87, None, 0x97, 0x8F, None, None,
None, None, None, None, 0x83, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'nop': [0xEA, None, None, 0x04, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rla': [None, None, None, 0x27, 0x37, None, 0x2F, 0x3F,
0x3B, None, None, None, None, None, 0x23, 0x33, None, None, None, None, None],
'rra': [None, None, None, 0x67, 0x77, None, 0x6F, 0x7F,
0x7B, None, None, None, None, None, 0x63, 0x73, None, None, None, None, None],
'sax': [None, None, None, 0x87, None, 0x97, 0x8F, None,
None, None, None, None, None, None, 0x83, None, None, None, None, None, None],
'sbx': [None, 0xCB, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'sha': [None, None, None, None, None, None, None, 0x9F,
None, None, None, None, None, 0x93, None, None],
'shs': [None, None, None, None, None, None, None, 0x9B,
None, None, None, None, None, None, None, None],
'shx': [None, None, None, None, None, None, None, 0x9E,
None, None, None, None, None, None, None, None],
'slo': [None, None, 0x07, 0x17, None, 0x0F, 0x1F, 0x1B,
None, None, None, None, 0x03, 0x13, None, None],
'sre': [None, None, 0x47, 0x57, None, 0x4F, 0x5F, 0x5B,
None, None, None, None, 0x43, 0x53, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'sha': [None, None, None, None, None, None, None, None,
0x9F, None, None, None, None, None, None, 0x93, None, None, None, None, None],
'shs': [None, None, None, None, None, None, None, None,
0x9B, None, None, None, None, None, None, None, None, None, None, None, None],
'shx': [None, None, None, None, None, None, None, None,
0x9E, None, None, None, None, None, None, None, None, None, None, None, None],
'slo': [None, None, None, 0x07, 0x17, None, 0x0F, 0x1F,
0x1B, None, None, None, None, None, 0x03, 0x13, None, None, None, None, None],
'sre': [None, None, None, 0x47, 0x57, None, 0x4F, 0x5F,
0x5B, None, None, None, None, None, 0x43, 0x53, None, None, None, None, None],
}
c02extensions = {
'adc': [None, 0x69, 0x65, 0x75, None, 0x6D, 0x7D, 0x79,
None, None, None, 0x72, 0x61, 0x71, None, None],
'and': [None, 0x29, 0x25, 0x35, None, 0x2D, 0x3D, 0x39,
None, None, None, 0x32, 0x21, 0x31, None, None],
'adc': [None, 0x69, None, 0x65, 0x75, None, 0x6D, 0x7D,
0x79, None, None, None, None, 0x72, 0x61, 0x71, None, None, None, None, None],
'and': [None, 0x29, None, 0x25, 0x35, None, 0x2D, 0x3D,
0x39, None, None, None, None, 0x32, 0x21, 0x31, None, None, None, None, None],
'bbr0': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0x0F],
None, None, None, None, None, None, None, None, None, None, None, None, 0x0F],
'bbr1': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0x1F],
None, None, None, None, None, None, None, None, None, None, None, None, 0x1F],
'bbr2': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0x2F],
None, None, None, None, None, None, None, None, None, None, None, None, 0x2F],
'bbr3': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0x3F],
None, None, None, None, None, None, None, None, None, None, None, None, 0x3F],
'bbr4': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0x4F],
None, None, None, None, None, None, None, None, None, None, None, None, 0x4F],
'bbr5': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0x5F],
None, None, None, None, None, None, None, None, None, None, None, None, 0x5F],
'bbr6': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0x6F],
None, None, None, None, None, None, None, None, None, None, None, None, 0x6F],
'bbr7': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0x7F],
None, None, None, None, None, None, None, None, None, None, None, None, 0x7F],
'bbs0': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0x8F],
None, None, None, None, None, None, None, None, None, None, None, None, 0x8F],
'bbs1': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0x9F],
None, None, None, None, None, None, None, None, None, None, None, None, 0x9F],
'bbs2': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0xAF],
None, None, None, None, None, None, None, None, None, None, None, None, 0xAF],
'bbs3': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0xBF],
None, None, None, None, None, None, None, None, None, None, None, None, 0xBF],
'bbs4': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0xCF],
None, None, None, None, None, None, None, None, None, None, None, None, 0xCF],
'bbs5': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0xDF],
None, None, None, None, None, None, None, None, None, None, None, None, 0xDF],
'bbs6': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0xEF],
None, None, None, None, None, None, None, None, None, None, None, None, 0xEF],
'bbs7': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, 0xFF],
'bit': [None, 0x89, 0x24, 0x34, None, 0x2C, 0x3C, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, 0xFF],
'bit': [None, 0x89, None, 0x24, 0x34, None, 0x2C, 0x3C,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'bra': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, 0x80, None],
'cmp': [None, 0xC9, 0xC5, 0xD5, None, 0xCD, 0xDD, 0xD9,
None, None, None, 0xD2, 0xC1, 0xD1, None, None],
None, None, None, None, None, None, None, None, None, None, 0x80, None, None],
'cmp': [None, 0xC9, None, 0xC5, 0xD5, None, 0xCD, 0xDD,
0xD9, None, None, None, None, 0xD2, 0xC1, 0xD1, None, None, None, None, None],
'dea': [0x3A, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'dec': [0x3A, None, 0xC6, 0xD6, None, 0xCE, 0xDE, None,
None, None, None, None, None, None, None, None],
'eor': [None, 0x49, 0x45, 0x55, None, 0x4D, 0x5D, 0x59,
None, None, None, 0x52, 0x41, 0x51, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'dec': [0x3A, None, None, 0xC6, 0xD6, None, 0xCE, 0xDE,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'eor': [None, 0x49, None, 0x45, 0x55, None, 0x4D, 0x5D,
0x59, None, None, None, None, 0x52, 0x41, 0x51, None, None, None, None, None],
'ina': [0x1A, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'inc': [0x1A, None, 0xE6, 0xF6, None, 0xEE, 0xFE, None,
None, None, None, None, None, None, None, None],
'jmp': [None, None, None, None, None, 0x4C, None, None,
0x6C, 0x7C, None, None, None, None, None, None],
'lda': [None, 0xA9, 0xA5, 0xB5, None, 0xAD, 0xBD, 0xB9,
None, None, None, 0xB2, 0xA1, 0xB1, None, None],
'ora': [None, 0x09, 0x05, 0x15, None, 0x0D, 0x1D, 0x19,
None, None, None, 0x12, 0x01, 0x11, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'inc': [0x1A, None, None, 0xE6, 0xF6, None, 0xEE, 0xFE,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'jmp': [None, None, None, None, None, None, 0x4C, None,
None, 0x6C, 0x7C, None, None, None, None, None, None, None, None, None, None],
'lda': [None, 0xA9, None, 0xA5, 0xB5, None, 0xAD, 0xBD,
0xB9, None, None, None, None, 0xB2, 0xA1, 0xB1, None, None, None, None, None],
'ora': [None, 0x09, None, 0x05, 0x15, None, 0x0D, 0x1D,
0x19, None, None, None, None, 0x12, 0x01, 0x11, None, None, None, None, None],
'phx': [0xDA, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'phy': [0x5A, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'plx': [0xFA, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'ply': [0x7A, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'rmb0': [None, None, 0x07, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'rmb1': [None, None, 0x17, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'rmb2': [None, None, 0x27, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'rmb3': [None, None, 0x37, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'rmb4': [None, None, 0x47, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'rmb5': [None, None, 0x57, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'rmb6': [None, None, 0x67, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'rmb7': [None, None, 0x77, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'sbc': [None, 0xE9, 0xE5, 0xF5, None, 0xED, 0xFD, 0xF9,
None, None, None, 0xF2, 0xE1, 0xF1, None, None],
'smb0': [None, None, 0x87, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'smb1': [None, None, 0x97, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'smb2': [None, None, 0xA7, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'smb3': [None, None, 0xB7, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'smb4': [None, None, 0xC7, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'smb5': [None, None, 0xD7, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'smb6': [None, None, 0xE7, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'smb7': [None, None, 0xF7, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'sta': [None, None, 0x85, 0x95, None, 0x8D, 0x9D, 0x99,
None, None, None, 0x92, 0x81, 0x91, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb0': [None, None, None, 0x07, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb1': [None, None, None, 0x17, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb2': [None, None, None, 0x27, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb3': [None, None, None, 0x37, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb4': [None, None, None, 0x47, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb5': [None, None, None, 0x57, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb6': [None, None, None, 0x67, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb7': [None, None, None, 0x77, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'sbc': [None, 0xE9, None, 0xE5, 0xF5, None, 0xED, 0xFD,
0xF9, None, None, None, None, 0xF2, 0xE1, 0xF1, None, None, None, None, None],
'smb0': [None, None, None, 0x87, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb1': [None, None, None, 0x97, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb2': [None, None, None, 0xA7, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb3': [None, None, None, 0xB7, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb4': [None, None, None, 0xC7, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb5': [None, None, None, 0xD7, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb6': [None, None, None, 0xE7, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb7': [None, None, None, 0xF7, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'sta': [None, None, None, 0x85, 0x95, None, 0x8D, 0x9D,
0x99, None, None, None, None, 0x92, 0x81, 0x91, None, None, None, None, None],
'stp': [0xDB, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
'stz': [None, None, 0x64, 0x74, None, 0x9C, 0x9E, None,
None, None, None, None, None, None, None, None],
'stz.w': [None, None, None, None, None, 0x9C, 0x9E, None,
None, None, None, None, None, None, None, None],
'trb': [None, None, 0x14, None, None, 0x1C, None, None,
None, None, None, None, None, None, None, None],
'trb.w': [None, None, None, None, None, 0x1C, None, None,
None, None, None, None, None, None, None, None],
'tsb': [None, None, 0x04, None, None, 0x0C, None, None,
None, None, None, None, None, None, None, None],
'tsb.w': [None, None, None, None, None, 0x0C, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
'stz': [None, None, None, 0x64, 0x74, None, 0x9C, 0x9E,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'stz.w': [None, None, None, None, None, None, 0x9C, 0x9E,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'trb': [None, None, None, 0x14, None, None, 0x1C, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'trb.w': [None, None, None, None, None, None, 0x1C, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'tsb': [None, None, None, 0x04, None, None, 0x0C, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'tsb.w': [None, None, None, None, None, None, 0x0C, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'wai': [0xCB, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None],
None, None, None, None, None, None, None, None, None, None, None, None, None],
}
csg4502extensions = {
'adc': [None, 0x69, None, 0x65, 0x75, None, 0x6D, 0x7D,
0x79, None, None, None, None, None, 0x61, 0x71, None, 0x72, None, None, None],
'and': [None, 0x29, None, 0x25, 0x35, None, 0x2D, 0x3D,
0x39, None, None, None, None, None, 0x21, 0x31, None, 0x32, None, None, None],
'asr': [0x43, None, None, None, 0x54, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'asw': [None, None, None, None, None, None, 0xCB, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'bbr0': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0x0F],
'bbr1': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0x1F],
'bbr2': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0x2F],
'bbr3': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0x3F],
'bbr4': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0x4F],
'bbr5': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0x5F],
'bbr6': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0x6F],
'bbr7': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0x7F],
'bbs0': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0x8F],
'bbs1': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0x9F],
'bbs2': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0xAF],
'bbs3': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0xBF],
'bbs4': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0xCF],
'bbs5': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0xDF],
'bbs6': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0xEF],
'bbs7': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, 0xFF],
'bcc': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, 0x90, 0x93, None],
'bcs': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, 0xB0, 0xB3, None],
'beq': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, 0xF0, 0xF3, None],
'bit': [None, 0x89, None, 0x24, 0x34, None, 0x2C, 0x3C,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'bmi': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, 0x30, 0x33, None],
'bne': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, 0xD0, 0xD3, None],
'bpl': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, 0x10, 0x13, None],
'bra': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, 0x80, 0x83, None],
'bsr': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, 0x63, None],
'bvc': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, 0x50, 0x53, None],
'bvs': [None, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, 0x70, 0x73, None],
'cle': [0x02, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'cmp': [None, 0xC9, None, 0xC5, 0xD5, None, 0xCD, 0xDD,
0xD9, None, None, None, None, None, 0xC1, 0xD1, None, 0xD2, None, None, None],
'cpz': [None, 0xC2, None, 0xD4, None, None, 0xDC, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'dea': [0x3A, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'dec': [0x3A, None, None, 0xC6, 0xD6, None, 0xCE, 0xDE,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'dew': [None, None, None, None, None, None, 0xC3, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'dez': [0x3B, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'eom': [0xEA, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'eor': [None, 0x49, None, 0x45, 0x55, None, 0x4D, 0x5D,
0x59, None, None, None, None, None, 0x41, 0x51, None, 0x52, None, None, None],
'inc': [0x1A, None, None, 0xE6, 0xF6, None, 0xEE, 0xFE,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'inw': [None, None, None, None, None, None, 0xE3, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'inz': [0x1B, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'jmp': [None, None, None, None, None, None, 0x4C, None,
None, 0x6C, 0x7C, None, None, None, None, None, None, None, None, None, None],
'jsr': [None, None, None, None, None, None, 0x20, None,
None, 0x22, 0x23, None, None, None, None, None, None, None, None, None, None],
'lda': [None, 0xA9, None, 0xA5, 0xB5, None, 0xAD, 0xBD,
0xB9, None, None, None, None, None, 0xA1, 0xB1, 0xE2, 0xB2, None, None, None],
'ldz': [None, 0xA3, None, None, None, None, 0xAB, 0xBB,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'map': [0x5C, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'neg': [0x42, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'ora': [None, 0x09, None, 0x05, 0x15, None, 0x0D, 0x1D,
0x19, None, None, None, None, None, 0x01, 0x11, None, 0x12, None, None, None],
'phw': [None, None, 0xF4, None, None, None, 0xFC, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'phx': [0xDA, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'phy': [0x5A, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'phz': [0xDB, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'plx': [0xFA, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'ply': [0x7A, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'plz': [0xFB, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb0': [None, None, None, 0x07, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb1': [None, None, None, 0x17, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb2': [None, None, None, 0x27, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb3': [None, None, None, 0x37, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb4': [None, None, None, 0x47, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb5': [None, None, None, 0x57, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb6': [None, None, None, 0x67, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rmb7': [None, None, None, 0x77, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'row': [None, None, None, None, None, None, 0xEB, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'rts': [0x60, 0x62, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'sbc': [None, 0xE9, None, 0xE5, 0xF5, None, 0xED, 0xFD,
0xF9, None, None, None, None, None, 0xE1, 0xF1, None, 0xF2, None, None, None],
'see': [0x03, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb0': [None, None, None, 0x87, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb1': [None, None, None, 0x97, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb2': [None, None, None, 0xA7, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb3': [None, None, None, 0xB7, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb4': [None, None, None, 0xC7, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb5': [None, None, None, 0xD7, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb6': [None, None, None, 0xE7, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'smb7': [None, None, None, 0xF7, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'sta': [None, None, None, 0x85, 0x95, None, 0x8D, 0x9D,
0x99, None, None, None, None, None, 0x81, 0x91, 0x82, 0x92, None, None, None],
'stx': [None, None, None, 0x86, None, 0x96, 0x8E, None,
0x9B, None, None, None, None, None, None, None, None, None, None, None, None],
'sty': [None, None, None, 0x84, 0x94, None, 0x8C, 0x8B,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'stz': [None, None, None, 0x64, 0x74, None, 0x9C, 0x9E,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'tab': [0x5B, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'taz': [0x4B, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'tba': [0x7B, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'trb': [None, None, None, 0x14, None, None, 0x1C, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'tsb': [None, None, None, 0x04, None, None, 0x0C, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'tsy': [0x0B, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'tys': [0x2B, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
'tza': [0x6B, None, None, None, None, None, None, None,
None, None, None, None, None, None, None, None, None, None, None, None, None],
}

View File

@ -255,9 +255,12 @@ class EasyModes(Pass):
name = "Easy addressing modes pass"
def visitMemory(self, node, env):
if Ops.opcodes[node.data[0]][14] is not None:
if Ops.opcodes[node.data[0]][Ops.modes.index("Relative")] is not None:
node.nodetype = "Relative"
return
if Ops.opcodes[node.data[0]][Ops.modes.index("RelativeLong")] is not None:
node.nodetype = "RelativeLong"
return
if node.data[1].hardcoded:
if not collapse_no_index(node, env):
node.nodetype = "Absolute"
@ -290,6 +293,16 @@ class EasyModes(Pass):
if not collapse_y_ind(node, env):
node.nodetype = "AbsIndY"
def visitPointerSPY(self, node, env):
if node.data[1].hardcoded:
if not collapse_spy_ind(node, env):
node.nodetype = "AbsIndSPY"
def visitPointerZ(self, node, env):
if node.data[1].hardcoded:
if not collapse_z_ind(node, env):
node.nodetype = "AbsIndZ"
def visitUnknown(self, node, env):
pass
@ -310,12 +323,21 @@ class PCTracker(Pass):
def visitImmediate(self, node, env):
env.incPC(2)
def visitImmediateLong(self, node, env):
env.incPC(3)
def visitIndirectX(self, node, env):
env.incPC(2)
def visitIndirectY(self, node, env):
env.incPC(2)
def visitIndirectSPY(self, node, env):
env.incPC(2)
def visitIndirectZ(self, node, env):
env.incPC(2)
def visitZPIndirect(self, node, env):
env.incPC(2)
@ -331,6 +353,9 @@ class PCTracker(Pass):
def visitRelative(self, node, env):
env.incPC(2)
def visitRelativeLong(self, node, env):
env.incPC(3)
def visitZPRelative(self, node, env):
env.incPC(3)
@ -352,6 +377,9 @@ class PCTracker(Pass):
def visitAbsIndY(self, node, env):
env.incPC(3)
def visitAbsIndZ(self, node, env):
env.incPC(3)
def visitMemory(self, node, env):
env.incPC(3)
@ -361,6 +389,9 @@ class PCTracker(Pass):
def visitMemoryY(self, node, env):
env.incPC(3)
def visitMemoryZ(self, node, env):
env.incPC(3)
def visitPointer(self, node, env):
env.incPC(3)
@ -430,6 +461,9 @@ class Collapse(PCTracker):
self.changed |= collapse_y(node, env)
PCTracker.visitMemoryY(self, node, env)
def visitMemoryZ(self, node, env):
PCTracker.visitMemoryZ(self, node, env)
def visitPointer(self, node, env):
self.changed |= collapse_no_index_ind(node, env)
PCTracker.visitPointer(self, node, env)
@ -446,9 +480,18 @@ class Collapse(PCTracker):
# the branch extension pass. Force them to Absolute equivalents
# if this happens.
def visitImmediate(self, node, env):
if node.data[1].value(env) >= 0x100:
if Ops.opcodes[node.data[0]][Ops.modes.index("ImmediateLong")] is not None:
node.nodetype = "ImmediateLong"
PCTracker.visitImmediateLong(self, node, env)
self.changed = True
return
PCTracker.visitImmediate(self, node, env)
def visitZeroPage(self, node, env):
if node.data[1].value(env) >= 0x100:
if Ops.opcodes[node.data[0]][5] is not None:
if Ops.opcodes[node.data[0]][Ops.modes.index("Absolute")] is not None:
node.nodetype = "Absolute"
PCTracker.visitAbsolute(self, node, env)
self.changed = True
@ -457,7 +500,7 @@ class Collapse(PCTracker):
def visitZeroPageX(self, node, env):
if node.data[1].value(env) >= 0x100:
if Ops.opcodes[node.data[0]][6] is not None:
if Ops.opcodes[node.data[0]][Ops.modes.index("Absolute, X")] is not None:
node.nodetype = "AbsoluteX"
PCTracker.visitAbsoluteX(self, node, env)
self.changed = True
@ -466,7 +509,7 @@ class Collapse(PCTracker):
def visitZeroPageY(self, node, env):
if node.data[1].value(env) >= 0x100:
if Ops.opcodes[node.data[0]][7] is not None:
if Ops.opcodes[node.data[0]][Ops.modes.index("Absolute, Y")] is not None:
node.nodetype = "AbsoluteY"
PCTracker.visitAbsoluteY(self, node, env)
self.changed = True
@ -478,7 +521,7 @@ def collapse_no_index(node, env):
"""Transforms a Memory node into a ZeroPage one if possible.
Returns boolean indicating whether or not it made the collapse."""
if node.data[1].value(env) < 0x100:
if Ops.opcodes[node.data[0]][2] is not None:
if Ops.opcodes[node.data[0]][Ops.modes.index("Zero Page")] is not None:
node.nodetype = "ZeroPage"
return True
return False
@ -488,7 +531,7 @@ def collapse_x(node, env):
"""Transforms a MemoryX node into a ZeroPageX one if possible.
Returns boolean indicating whether or not it made the collapse."""
if node.data[1].value(env) < 0x100:
if Ops.opcodes[node.data[0]][3] is not None:
if Ops.opcodes[node.data[0]][Ops.modes.index("Zero Page, X")] is not None:
node.nodetype = "ZeroPageX"
return True
return False
@ -498,17 +541,16 @@ def collapse_y(node, env):
"""Transforms a MemoryY node into a ZeroPageY one if possible.
Returns boolean indicating whether or not it made the collapse."""
if node.data[1].value(env) < 0x100:
if Ops.opcodes[node.data[0]][4] is not None:
if Ops.opcodes[node.data[0]][Ops.modes.index("Zero Page, Y")] is not None:
node.nodetype = "ZeroPageY"
return True
return False
def collapse_no_index_ind(node, env):
"""Transforms a Pointer node into a ZPIndirect one if possible.
Returns boolean indicating whether or not it made the collapse."""
if node.data[1].value(env) < 0x100:
if Ops.opcodes[node.data[0]][11] is not None:
if Ops.opcodes[node.data[0]][Ops.modes.index("(Zero Page)")] is not None:
node.nodetype = "ZPIndirect"
return True
return False
@ -518,7 +560,7 @@ def collapse_x_ind(node, env):
"""Transforms a PointerX node into an IndirectX one if possible.
Returns boolean indicating whether or not it made the collapse."""
if node.data[1].value(env) < 0x100:
if Ops.opcodes[node.data[0]][12] is not None:
if Ops.opcodes[node.data[0]][Ops.modes.index("(Zero Page, X)")] is not None:
node.nodetype = "IndirectX"
return True
return False
@ -528,11 +570,29 @@ def collapse_y_ind(node, env):
"""Transforms a PointerY node into an IndirectY one if possible.
Returns boolean indicating whether or not it made the collapse."""
if node.data[1].value(env) < 0x100:
if Ops.opcodes[node.data[0]][13] is not None:
if Ops.opcodes[node.data[0]][Ops.modes.index("(Zero Page), Y")] is not None:
node.nodetype = "IndirectY"
return True
return False
def collapse_spy_ind(node, env):
"""Transforms a PointerSPY node into an IndirectY one if possible.
Returns boolean indicating whether or not it made the collapse."""
if node.data[1].value(env) < 0x100:
if Ops.opcodes[node.data[0]][Ops.modes.index("(Zero Page, SP), Y")] is not None:
node.nodetype = "IndirectSPY"
return True
return False
def collapse_z_ind(node, env):
"""Transforms a PointerZ node into an IndirectZ one if possible.
Returns boolean indicating whether or not it made the collapse."""
if node.data[1].value(env) < 0x100:
if Ops.opcodes[node.data[0]][Ops.modes.index("(Zero Page), Z")] is not None:
node.nodetype = "IndirectZ"
return True
return False
class ExtendBranches(PCTracker):
"""Eliminates any branch instructions that would end up going past
@ -573,35 +633,41 @@ class ExtendBranches(PCTracker):
arg = expr.value(env)
arg = arg - (env.getPC() + 2)
if arg < -128 or arg > 127:
if opcode == 'bra':
# If BRA - BRanch Always - is out of range, it's a JMP.
node.data = ('jmp', expr, None)
node.nodetype = "Absolute"
if Cmd.enable_4502_exts:
node.nodetype = "RelativeLong"
if Cmd.warn_on_branch_extend:
print>>sys.stderr, str(node.ppt) + ": WARNING: " \
"bra out of range, replacing with jmp"
"branch out of range, replacing with 16-bit relative branch"
else:
# Otherwise, we replace it with a 'macro' of sorts by hand:
# $branch LOC -> $reversed_branch ^+5; JMP LOC
# We don't use temp labels here because labels need to have
# been fixed in place by this point, and JMP is always 3
# bytes long.
expansion = [IR.Node(node.ppt, "Relative",
if opcode == 'bra':
# If BRA - BRanch Always - is out of range, it's a JMP.
node.data = ('jmp', expr, None)
node.nodetype = "Absolute"
if Cmd.warn_on_branch_extend:
print>>sys.stderr, str(node.ppt) + ": WARNING: " \
"bra out of range, replacing with jmp"
else:
# Otherwise, we replace it with a 'macro' of sorts by hand:
# $branch LOC -> $reversed_branch ^+5; JMP LOC
# We don't use temp labels here because labels need to have
# been fixed in place by this point, and JMP is always 3
# bytes long.
expansion = [IR.Node(node.ppt, "Relative",
ExtendBranches.reversed[opcode],
IR.SequenceExpr([IR.PCExpr(), "+",
IR.ConstantExpr(5)]),
None),
IR.Node(node.ppt, "Absolute", 'jmp', expr, None)]
node.nodetype = 'SEQUENCE'
node.data = expansion
if Cmd.warn_on_branch_extend:
print>>sys.stderr, str(node.ppt) + ": WARNING: " + \
node.nodetype = 'SEQUENCE'
node.data = expansion
if Cmd.warn_on_branch_extend:
print>>sys.stderr, str(node.ppt) + ": WARNING: " + \
opcode + " out of range, " \
"replacing with " + \
ExtendBranches.reversed[opcode] + \
"/jmp combo"
self.changed = True
node.accept(self, env)
self.changed = True
node.accept(self, env)
else:
PCTracker.visitRelative(self, node, env)
@ -660,6 +726,9 @@ class NormalizeModes(Pass):
def visitPointerY(self, node, env):
node.nodetype = "AbsIndY"
def visitPointerZ(self, node, env):
node.nodetype = "AbsIndZ"
def visitUnknown(self, node, env):
pass
@ -778,11 +847,20 @@ class Assembler(Pass):
arg += 256
return IR.ConstantExpr(arg)
def relativizelong(self, expr, env, arglen):
"Convert an expression into one for use in relative addressing"
arg = expr.value(env)
arg = arg - (env.getPC() + arglen)
if arg < 0:
arg += 65536
return IR.ConstantExpr(arg)
def listing_string(self, pc, binary, mode, opcode, val1, val2):
base = " %04X " % pc
base += (" %02X" * len(binary)) % tuple(binary)
formats = ["",
"#$%02X",
"#$%04X",
"$%02X",
"$%02X, X",
"$%02X, Y",
@ -792,9 +870,13 @@ class Assembler(Pass):
"($%04X)",
"($%04X, X)",
"($%04X), Y",
"($%04X), Z",
"($%02X)",
"($%02X, X)",
"($%02X), Y",
"($%02X, SP), Y",
"($%02X), Z",
"$%04X",
"$%04X",
"$%02X, $%04X"]
fmt = ("%-16s %-5s" % (base, opcode.upper())) + formats[mode]
@ -805,7 +887,7 @@ class Assembler(Pass):
mask = 0xFF
# Relative is a full address in a byte, so it also has the
# 0xFFFF mask.
if arglen == 2 or mode == 14:
if arglen == 2 or mode == 17:
mask = 0xFFFF
return fmt % (val1 & mask)
else:
@ -829,13 +911,15 @@ class Assembler(Pass):
val1 = expr.value(env)
if expr2 is not None:
val2 = expr2.value(env)
if mode == 15: # ZP Relative mode is wildly nonstandard
if mode == Ops.modes.index("Zero Page, Relative"):
expr2 = self.relativize(expr2, env, arglen)
self.outputbyte(expr, env, inst_bytes)
self.outputbyte(expr2, env, inst_bytes)
else:
if mode == 14:
if mode == Ops.modes.index("Relative"):
expr = self.relativize(expr, env, arglen)
elif mode == Ops.modes.index("RelativeLong"):
expr = self.relativizelong(expr, env, arglen)
if arglen == 1:
self.outputbyte(expr, env, inst_bytes)
elif arglen == 2:
@ -848,52 +932,67 @@ class Assembler(Pass):
self.code += 1 + arglen
def visitImplied(self, node, env):
self.assemble(node, 0, env)
self.assemble(node, Ops.modes.index("Implied"), env)
def visitImmediate(self, node, env):
self.assemble(node, 1, env)
self.assemble(node, Ops.modes.index("Immediate"), env)
def visitImmediateLong(self, node, env):
self.assemble(node, Ops.modes.index("ImmediateLong"), env)
def visitZeroPage(self, node, env):
self.assemble(node, 2, env)
self.assemble(node, Ops.modes.index("Zero Page"), env)
def visitZeroPageX(self, node, env):
self.assemble(node, 3, env)
self.assemble(node, Ops.modes.index("Zero Page, X"), env)
def visitZeroPageY(self, node, env):
self.assemble(node, 4, env)
self.assemble(node, Ops.modes.index("Zero Page, Y"), env)
def visitAbsolute(self, node, env):
self.assemble(node, 5, env)
self.assemble(node, Ops.modes.index("Absolute"), env)
def visitAbsoluteX(self, node, env):
self.assemble(node, 6, env)
self.assemble(node, Ops.modes.index("Absolute, X"), env)
def visitAbsoluteY(self, node, env):
self.assemble(node, 7, env)
self.assemble(node, Ops.modes.index("Absolute, Y"), env)
def visitIndirect(self, node, env):
self.assemble(node, 8, env)
self.assemble(node, Ops.modes.index("(Absolute)"), env)
def visitAbsIndX(self, node, env):
self.assemble(node, 9, env)
self.assemble(node, Ops.modes.index("(Absolute, X)"), env)
def visitAbsIndY(self, node, env):
self.assemble(node, 10, env)
self.assemble(node, Ops.modes.index("(Absolute), Y"), env)
def visitAbsIndZ(self, node, env):
self.assemble(node, Ops.modes.index("(Absolute), Z"), env)
def visitZPIndirect(self, node, env):
self.assemble(node, 11, env)
self.assemble(node, Ops.modes.index("(Zero Page)"), env)
def visitIndirectX(self, node, env):
self.assemble(node, 12, env)
self.assemble(node, Ops.modes.index("(Zero Page, X)"), env)
def visitIndirectY(self, node, env):
self.assemble(node, 13, env)
self.assemble(node, Ops.modes.index("(Zero Page), Y"), env)
def visitIndirectZ(self, node, env):
self.assemble(node, Ops.modes.index("(Zero Page), Z"), env)
def visitIndirectSPY(self, node, env):
self.assemble(node, Ops.modes.index("(Zero Page, SP), Y"), env)
def visitRelative(self, node, env):
self.assemble(node, 14, env)
self.assemble(node, Ops.modes.index("Relative"), env)
def visitRelativeLong(self, node, env):
self.assemble(node, Ops.modes.index("RelativeLong"), env)
def visitZPRelative(self, node, env):
self.assemble(node, 15, env)
self.assemble(node, Ops.modes.index("Zero Page, Relative"), env)
def visitLabel(self, node, env):
pass

View File

@ -1,3 +1,5 @@
opcodes: op6502.txt
undocops: op6510.txt
c02extensions: op65c02.txt
csg4502extensions: op4502.txt

View File

@ -17,45 +17,56 @@ prologue = '"""' + """Opcodes file.
# the tables in tools/opcodes. Edit those tables, not these.
# Names of addressing modes
modes = ["Implied", # 0
"Immediate", # 1
"Zero Page", # 2
"Zero Page, X", # 3
"Zero Page, Y", # 4
"Absolute", # 5
"Absolute, X", # 6
"Absolute, Y", # 7
"(Absolute)", # 8
"(Absolute, X)", # 9
"(Absolute), Y", # 10
"(Zero Page)", # 11
"(Zero Page, X)", # 12
"(Zero Page), Y", # 13
"Relative", # 14
"Zero Page, Relative"] # 15
modes = ["Implied",
"Immediate",
"ImmediateLong",
"Zero Page",
"Zero Page, X",
"Zero Page, Y",
"Absolute",
"Absolute, X",
"Absolute, Y",
"(Absolute)",
"(Absolute, X)",
"(Absolute), Y",
"(Absolute), Z",
"(Zero Page)",
"(Zero Page, X)",
"(Zero Page), Y",
"(Zero Page, SP), Y",
"(Zero Page), Z",
"Relative",
"RelativeLong",
"Zero Page, Relative"]
# Lengths of the argument
lengths = [0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2]
lengths = [0, 1, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2]
"""
# These values should match the ones in the prologue string.
modes = ["Implied", # 0
"Immediate", # 1
"Zero Page", # 2
"Zero Page, X", # 3
"Zero Page, Y", # 4
"Absolute", # 5
"Absolute, X", # 6
"Absolute, Y", # 7
"(Absolute)", # 8
"(Absolute, X)", # 9
"(Absolute), Y", # 10
"(Zero Page)", # 11
"(Zero Page, X)", # 12
"(Zero Page), Y", # 13
"Relative", # 14
"Zero Page, Relative"] # 15
modes = ["Implied",
"Immediate",
"Immediate.W",
"Zero Page",
"Zero Page, X",
"Zero Page, Y",
"Absolute",
"Absolute, X",
"Absolute, Y",
"(Absolute)",
"(Absolute, X)",
"(Absolute), Y",
"(Absolute), Z",
"(Zero Page)",
"(Zero Page, X)",
"(Zero Page), Y",
"(Zero Page, SP), Y",
"(Zero Page), Z",
"Relative",
"RelativeLong",
"Zero Page, Relative"]
flatmodes = [x.lower() for x in modes]

View File

@ -0,0 +1,256 @@
00: BRK - Implied
01: ORA - (Zero Page, X)
02: CLE - Implied
03: SEE - Implied
04: TSB - Zero Page
05: ORA - Zero Page
06: ASL - Zero Page
07: RMB0 - Zero Page
08: PHP - Implied
09: ORA - Immediate
0A: ASL - Implied
0B: TSY - Implied
0C: TSB - Absolute
0D: ORA - Absolute
0E: ASL - Absolute
0F: BBR0 - Zero Page, Relative
10: BPL - Relative
11: ORA - (Zero Page), Y
12: ORA - (Zero Page), Z
13: BPL - RelativeLong
14: TRB - Zero Page
15: ORA - Zero Page, X
16: ASL - Zero Page, X
17: RMB1 - Zero Page
18: CLC - Implied
19: ORA - Absolute, Y
1A: INC - Implied
1B: INZ - Implied
1C: TRB - Absolute
1D: ORA - Absolute, X
1E: ASL - Absolute, X
1F: BBR1 - Zero Page, Relative
20: JSR - Absolute
21: AND - (Zero Page, X)
22: JSR - (Absolute)
23: JSR - (Absolute, X)
24: BIT - Zero Page
25: AND - Zero Page
26: ROL - Zero Page
27: RMB2 - Zero Page
28: PLP - Implied
29: AND - Immediate
2A: ROL - Implied
2B: TYS - Implied
2C: BIT - Absolute
2D: AND - Absolute
2E: ROL - Absolute
2F: BBR2 - Zero Page, Relative
30: BMI - Relative
31: AND - (Zero Page), Y
32: AND - (Zero Page), Z
33: BMI - RelativeLong
34: BIT - Zero Page, X
35: AND - Zero Page, X
36: ROL - Zero Page, X
37: RMB3 - Zero Page
38: SEC - Implied
39: AND - Absolute, Y
3A: DEA - Implied; DEC - Implied
3B: DEZ - Implied
3C: BIT - Absolute, X
3D: AND - Absolute, X
3E: ROL - Absolute, X
3F: BBR3 - Zero Page, Relative
40: RTI - Implied
41: EOR - (Zero Page, X)
42: NEG - Implied
43: ASR - Implied
44: ASR Zero Page
45: EOR - Zero Page
46: LSR - Zero Page
47: RMB4 - Zero Page
48: PHA - Implied
49: EOR - Immediate
4A: LSR - Implied
4B: TAZ - Implied
4C: JMP - Absolute
4D: EOR - Absolute
4E: LSR - Absolute
4F: BBR4 - Zero Page, Relative
50: BVC - Relative
51: EOR - (Zero Page), Y
52: EOR - (Zero Page), Z
53: BVC - RelativeLong
54: ASR - Zero Page, X
55: EOR - Zero Page, X
56: LSR - Zero Page, X
57: RMB5 - Zero Page
58: CLI - Implied
59: EOR - Absolute, Y
5A: PHY - Implied
5B: TAB - Implied
5C: MAP - Implied
5D: EOR - Absolute, X
5E: LSR - Absolute, X
5F: BBR5 - Zero Page, Relative
60: RTS - Implied
61: ADC - (Zero Page, X)
62: RTS - Immediate
63: BSR - RelativeLong
64: STZ - Zero Page
65: ADC - Zero Page
66: ROR - Zero Page
67: RMB6 - Zero Page
68: PLA - Implied
69: ADC - Immediate
6A: ROR - Implied
6B: TZA - Implied
6C: JMP - (Absolute)
6D: ADC - Absolute
6E: ROR - Absolute
6F: BBR6 - Zero Page, Relative
70: BVS - Relative
71: ADC - (Zero Page), Y
72: ADC - (Zero Page), Z
73: BVS - RelativeLong
74: STZ - Zero Page, X
75: ADC - Zero Page, X
76: ROR - Zero Page, X
77: RMB7 - Zero Page
78: SEI - Implied
79: ADC - Absolute, Y
7A: PLY - Implied
7B: TBA - Implied
7C: JMP - (Absolute, X)
7D: ADC - Absolute, X
7E: ROR - Absolute, X
7F: BBR7 - Zero Page, Relative
80: BRA - Relative
81: STA - (Zero Page, X)
82: STA - (Zero Page, SP), Y
83: BRA - RelativeLong
84: STY - Zero Page
85: STA - Zero Page
86: STX - Zero Page
87: SMB0 - Zero Page
88: DEY - Implied
89: BIT - Immediate
8A: TXA - Implied
8B: STY - Absolute, X
8C: STY - Absolute
8D: STA - Absolute
8E: STX - Absolute
8F: BBS0 - Zero Page, Relative
90: BCC - Relative
91: STA - (Zero Page), Y
92: STA - (Zero Page), Z
93: BCC - RelativeLong
94: STY - Zero Page, X
95: STA - Zero Page, X
96: STX - Zero Page, Y
97: SMB1 - Zero Page
98: TYA - Implied
99: STA - Absolute, Y
9A: TXS - Implied
9B: STX - Absolute, Y
9C: STZ - Absolute
9D: STA - Absolute, X
9E: STZ - Absolute, X
9F: BBS1 - Zero Page, Relative
A0: LDY - Immediate
A1: LDA - (Zero Page, X)
A2: LDX - Immediate
A3: LDZ - Immediate
A4: LDY - Zero Page
A5: LDA - Zero Page
A6: LDX - Zero Page
A7: SMB2 - Zero Page
A8: TAY - Implied
A9: LDA - Immediate
AA: TAX - Implied
AB: LDZ - Absolute
AC: LDY - Absolute
AD: LDA - Absolute
AE: LDX - Absolute
AF: BBS2 - Zero Page, Relative
B0: BCS - Relative
B1: LDA - (Zero Page), Y
B2: LDA - (Zero Page), Z
B3: BCS - RelativeLong
B4: LDY - Zero Page, X
B5: LDA - Zero Page, X
B6: LDX - Zero Page, Y
B7: SMB3 - Zero Page
B8: CLV - Implied
B9: LDA - Absolute, Y
BA: TSX - Implied
BB: LDZ - Absolute, X
BC: LDY - Absolute, X
BD: LDA - Absolute, X
BE: LDX - Absolute, Y
BF: BBS3 - Zero Page, Relative
C0: CPY - Immediate
C1: CMP - (Zero Page, X)
C2: CPZ - Immediate
C3: DEW - Absolute
C4: CPY - Zero Page
C5: CMP - Zero Page
C6: DEC - Zero Page
C7: SMB4 - Zero Page
C8: INY - Implied
C9: CMP - Immediate
CA: DEX - Implied
CB: ASW - Absolute
CC: CPY - Absolute
CD: CMP - Absolute
CE: DEC - Absolute
CF: BBS4 - Zero Page, Relative
D0: BNE - Relative
D1: CMP - (Zero Page), Y
D2: CMP - (Zero Page), Z
D3: BNE - RelativeLong
D4: CPZ - Zero Page
D5: CMP - Zero Page, X
D6: DEC - Zero Page, X
D7: SMB5 - Zero Page
D8: CLD - Implied
D9: CMP - Absolute, Y
DA: PHX - Implied
DB: PHZ - Implied
DC: CPZ - Absolute
DD: CMP - Absolute, X
DE: DEC - Absolute, X
DF: BBS5 - Zero Page, Relative
E0: CPX - Immediate
E1: SBC - (Zero Page, X)
E2: LDA - (Zero Page, SP), Y
E3: INW - Absolute
E4: CPX - Zero Page
E5: SBC - Zero Page
E6: INC - Zero Page
E7: SMB6 - Zero Page
E8: INX - Implied
E9: SBC - Immediate
EA: NOP - Implied; EOM - Implied
EB: ROW - Absolute
EC: CPX - Absolute
ED: SBC - Absolute
EE: INC - Absolute
EF: BBS6 - Zero Page, Relative
F0: BEQ - Relative
F1: SBC - (Zero Page), Y
F2: SBC - (Zero Page), Z
F3: BEQ - RelativeLong
F4: PHW - Immediate.W
F5: SBC - Zero Page, X
F6: INC - Zero Page, X
F7: SMB7 - Zero Page
F8: SED - Implied
F9: SBC - Absolute, Y
FA: PLX - Implied
FB: PLZ - Implied
FC: PHW - Absolute
FD: SBC - Absolute, X
FE: INC - Absolute, X
FF: BBS7 - Zero Page, Relative

106
tests/test4502.oph Normal file
View File

@ -0,0 +1,106 @@
; Test file for 4502 extended opcode compliance
; This odd little source file uses every addressing mode
; of every opcode, and uses the opcode itself as the argument
; to each instruction that takes one. The resulting binary's
; bytes are thus in strictly increasing numerical order.
; Some opcodes have multiple mnemonics; we provide both.
; This file also doesn't include the 4502's opcodes that
; are also available in stock 6502s - see testbase.oph for
; those. However, it does include those extensions share
; with the 65C02.
CLE ; 02: CLE - Implied
SEE ; 03: SEE - Implied
TSB $04 ; 04: TSB - Zero Page
RMB0 $07 ; 07: RMB0 - Zero Page
TSY ; 0B: TSY - Implied
TSB $0C0C ; 0C: TSB - Absolute
BBR0 $0F, ^+$12 ; 0F: BBR0 - Zero Page, Relative
ORA ($12), Z ; 12: ORA - (Zero Page), Z
TRB $14 ; 14: TRB - Zero Page
RMB1 $17 ; 17: RMB1 - Zero Page
INC ; 1A: INC - Implied
INZ ; 1B: INZ - Implied
TRB $1C1C ; 1C: TRB - Absolute
BBR1 $1F, ^+$22 ; 1F: BBR1 - Zero Page, Relative
JSR ($2222) ; 22: JSR - (Absolute)
JSR ($2323,X) ; 23: JSR - (Absolute, X)
RMB2 $27 ; 27: RMB2 - Zero Page
TYS ; 2B: TYS - Implied
BBR2 $2F, ^+$32 ; 2F: BBR2 - Zero Page, Relative
AND ($32), Z ; 32: AND - (Zero Page), Z
BIT $34, X ; 34: BIT - Zero Page, X
RMB3 $37 ; 37: RMB3 - Zero Page
DEA ; 3A: DEA - Implied
DEC ; 3A: DEC - Implied
DEZ ; 3B: DEZ - Implied
BIT $3C3C,X ; 3C: BIT - Absolute, X
BBR3 $3F, ^+$42 ; 3F: BBR3 - Zero Page, Relative
NEG ; 42: NEG - Implied
ASR ; 43: ASR - Implied
RMB4 $47 ; 47: RMB4 - Zero Page
TAZ ; 4B: TAZ - Implied
BBR4 $4F, ^+$52 ; 4F: BBR4 - Zero Page, Relative
EOR ($52),Z ; 52: EOR - (Zero Page), Z
RMB5 $57 ; 57: RMB5 - Zero Page
PHY ; 5A: PHY - Implied
TAB ; 5B: TAB - Implied
MAP ; 5C: MAP - Implied
BBR5 $5F, ^+$62 ; 5F: BBR5 - Zero Page, Relative
RTS #$62 ; 62: RTS - Immediate
STZ $64 ; 64: STZ - Zero Page
RMB6 $67 ; 67: RMB6 - Zero Page
TZA ; 6B: TZA - Implied
JMP ($6C6C) ; 6C: JMP - (Absolute)
BBR6 $6F, ^+$72 ; 6F: BBR6 - Zero Page, Relative
ADC ($72), Z ; 72: ADC - (Zero Page), Z
STZ $74, X ; 74: STZ - Zero Page, X
RMB7 $77 ; 77: RMB7 - Zero Page
PLY ; 7A: PLY - Implied
TBA ; 7B: TBA - Implied
JMP ($7C7C, X) ; 7C: JMP - (Absolute, X)
BBR7 $7F, ^+$82 ; 7F: BBR7 - Zero Page, Relative
BRA ^-$7E ; 80: BRA - Relative
SMB0 $87 ; 87: SMB0 - Zero Page
BIT #$89 ; 89: BIT - Immediate
STY $8B8B,X ; 8B: STY - Absolute, X
BBS0 $8F, ^-$6E ; 8F: BBS0 - Zero Page, Relative
STA ($92),Z ; 92: STA - (Zero Page), Z
SMB1 $97 ; 97: SMB1 - Zero Page
STX $9B9B,Y ; 9B: STX - Absolute, Y
STZ $9C9C ; 9C: STZ - Absolute
STZ $9E9E, X ; 9E: STZ - Absolute, X
BBS1 $9F, ^-$5E ; 9F: BBS1 - Zero Page, Relative
LDZ #$A3 ; A3: LDZ - Immediate
SMB2 $A7 ; A7: SMB2 - Zero Page
LDZ $ABAB ; AB: LDZ - Absolute
BBS2 $AF, ^-$4E ; AF: BBS2 - Zero Page, Relative
LDA ($B2),Z ; B2: LDA - (Zero Page), Z
SMB3 $B7 ; B7: SMB3 - Zero Page
LDZ $BBBB,X ; BB: LDZ - Absolute, X
LDY $BCBC,X ; BC: LDY - Absolute, X
BBS3 $BF, ^-$3E ; BF: BBS3 - Zero Page, Relative
CPZ #$C2 ; C2: CPZ - Immediate
DEW $C3C3 ; C3: DEW - Absolute
SMB4 $C7 ; C7: SMB4 - Zero Page
ASW $CBCB ; CB: ASW - Absolute
BBS4 $CF, ^-$2E ; CF: BBS4 - Zero Page, Relative
CMP ($D2),Z ; D2: CMP - (Zero Page), Z
SMB5 $D7 ; D7: SMB5 - Zero Page
PHX ; DA: PHX - Implied
PHZ ; DB: PHZ - Implied
BBS5 $DF, ^-$1E ; DF: BBS5 - Zero Page, Relative
LDA ($E2,SP),Y ; E2: LDA - (Zero Page, SP), Y
INW $E3E3 ; E3: INW - Absolute
PHW #$E4E4 ; E4: PHW - ImmediateLong
SMB6 $E7 ; E7: SMB6 - Zero Page
EOM ; EA: EOM - Implied
ROW $EBEB ; EB: ROW - Absolute
BBS6 $EF, ^-$0E ; EF: BBS6 - Zero Page, Relative
SBC ($F2), Z ; F2: SBC - (Zero Page), Z
SMB7 $F7 ; F7: SMB7 - Zero Page
PLX ; FA: PLX - Implied
PLZ ; FB: PLZ - Implied
PHW $FCFC ; FC: PHW - Absolute
BBS7 $FF, ^+$02 ; FF: BBS7 - Zero Page, Relative

View File

@ -82,6 +82,7 @@ def test_basic():
test_file('Undocumented instructions', 'test6510.oph', 'test6510.bin',
['-u'])
test_file('65c02 extensions', 'test65c02.oph', 'test65c02.bin', ['-c'])
test_file('4502 extensions', 'test4502.oph', 'test4502.bin', ['-4'])
test_file('Wide instructions', 'testwide.oph', 'testwide.bin', ['-c'])
test_file('Branch restrictions (6502)', 'longbranch.oph', None,
['--no-branch-extend'])