diff --git a/1802.py b/1802.py new file mode 100644 index 0000000..aee52b9 --- /dev/null +++ b/1802.py @@ -0,0 +1,314 @@ +######################################################################### +# +# Processor specific code + +# CPU = "1802" +# Description = "RCA 1802 COSMAC 8-bit microprocessor." +# DataWidth = 8 # 8-bit data +# AddressWidth = 16 # 16-bit addresses +# +# See: +# https://en.wikipedia.org/wiki/RCA_1802 +# https://www.atarimagazines.com/computeii/issue3/page52.php +# http://www.massmind.org/techref/1802/index.htm + +# Maximum length of an instruction (for formatting purposes) +maxLength = 3 + +# Leadin bytes for multibyte instructions +leadInBytes = [] + +# Addressing mode table +# List of addressing modes and corresponding format strings for operands. +addressModeTable = { +"one" : "", +"two" : "${0:02X}", +"three" : "${0:02X}{1:02X}", +} + + +# Op Code Table +# Key is numeric opcode (possibly multiple bytes) +# Value is a list: +# # bytes +# mnemonic +# addressing mode +# flags (e.g. pcr) +opcodeTable = { +0x00 : [ 1, "idl", "one" ], +0x01 : [ 1, "ld 1", "one" ], +0x02 : [ 1, "ld 2", "one" ], +0x03 : [ 1, "ld 3", "one" ], +0x04 : [ 1, "ld 4", "one" ], +0x05 : [ 1, "ld 5", "one" ], +0x06 : [ 1, "ld 6", "one" ], +0x07 : [ 1, "ld 7", "one" ], +0x08 : [ 1, "ld 8", "one" ], +0x09 : [ 1, "ld 9", "one" ], +0x0a : [ 1, "ld 10", "one" ], +0x0b : [ 1, "ld 11", "one" ], +0x0c : [ 1, "ld 12", "one" ], +0x0d : [ 1, "ld 13", "one" ], +0x0e : [ 1, "ld 14", "one" ], +0x0f : [ 1, "ld 15", "one" ], + +0x10 : [ 1, "inc", "one" ], +0x11 : [ 1, "inc", "one" ], +0x12 : [ 1, "inc", "one" ], +0x13 : [ 1, "inc", "one" ], +0x14 : [ 1, "inc", "one" ], +0x15 : [ 1, "inc", "one" ], +0x16 : [ 1, "inc", "one" ], +0x17 : [ 1, "inc", "one" ], +0x18 : [ 1, "inc", "one" ], +0x19 : [ 1, "inc", "one" ], +0x1a : [ 1, "inc", "one" ], +0x1b : [ 1, "inc", "one" ], +0x1c : [ 1, "inc", "one" ], +0x1d : [ 1, "inc", "one" ], +0x1e : [ 1, "inc", "one" ], +0x1f : [ 1, "inc", "one" ], + +0x20 : [ 1, "dec", "one" ], +0x21 : [ 1, "dec", "one" ], +0x22 : [ 1, "dec", "one" ], +0x23 : [ 1, "dec", "one" ], +0x24 : [ 1, "dec", "one" ], +0x25 : [ 1, "dec", "one" ], +0x26 : [ 1, "dec", "one" ], +0x27 : [ 1, "dec", "one" ], +0x28 : [ 1, "dec", "one" ], +0x29 : [ 1, "dec", "one" ], +0x2a : [ 1, "dec", "one" ], +0x2b : [ 1, "dec", "one" ], +0x2c : [ 1, "dec", "one" ], +0x2d : [ 1, "dec", "one" ], +0x2e : [ 1, "dec", "one" ], +0x2f : [ 1, "dec", "one" ], + +0x30 : [ 2, "br", "two" ], +0x31 : [ 2, "bq", "two" ], +0x32 : [ 2, "bz", "two" ], +0x33 : [ 2, "bdf", "two" ], +0x34 : [ 2, "b1", "two" ], +0x35 : [ 2, "b2", "two" ], +0x36 : [ 2, "b3", "two" ], +0x37 : [ 2, "b4", "two" ], +0x38 : [ 2, "nbr", "two" ], +#0x38: [ 2, "skp", "two" ], Alternate mnemonic for above +0x39 : [ 2, "bnq", "two" ], +0x3a : [ 2, "bnz", "two" ], +0x3b : [ 2, "bnf", "two" ], +0x3c : [ 2, "bn1", "two" ], +0x3d : [ 2, "bn2", "two" ], +0x3e : [ 2, "bn3", "two" ], +0x3f : [ 2, "bn4", "two" ], + +0x40 : [ 1, "lda", "one" ], +0x41 : [ 1, "lda", "one" ], +0x42 : [ 1, "lda", "one" ], +0x43 : [ 1, "lda", "one" ], +0x44 : [ 1, "lda", "one" ], +0x45 : [ 1, "lda", "one" ], +0x46 : [ 1, "lda", "one" ], +0x47 : [ 1, "lda", "one" ], +0x48 : [ 1, "lda", "one" ], +0x49 : [ 1, "lda", "one" ], +0x4a : [ 1, "lda", "one" ], +0x4b : [ 1, "lda", "one" ], +0x4c : [ 1, "lda", "one" ], +0x4d : [ 1, "lda", "one" ], +0x4e : [ 1, "lda", "one" ], +0x4f : [ 1, "lda", "one" ], + +0x50 : [ 1, "str", "one" ], +0x51 : [ 1, "str", "one" ], +0x52 : [ 1, "str", "one" ], +0x53 : [ 1, "str", "one" ], +0x54 : [ 1, "str", "one" ], +0x55 : [ 1, "str", "one" ], +0x56 : [ 1, "str", "one" ], +0x57 : [ 1, "str", "one" ], +0x58 : [ 1, "str", "one" ], +0x59 : [ 1, "str", "one" ], +0x5a : [ 1, "str", "one" ], +0x5b : [ 1, "str", "one" ], +0x5c : [ 1, "str", "one" ], +0x5d : [ 1, "str", "one" ], +0x5e : [ 1, "str", "one" ], +0x5f : [ 1, "str", "one" ], + +0x60 : [ 1, "irx", "one" ], +0x61 : [ 1, "out 1,", "one" ], +0x62 : [ 1, "out 2,", "one" ], +0x63 : [ 1, "out 3,", "one" ], +0x64 : [ 2, "out 4,", "two" ], +0x65 : [ 1, "out 5,", "one" ], +0x66 : [ 1, "out 6,", "one" ], +0x67 : [ 1, "out 7,", "one" ], + +0x69 : [ 1, "inp 1", "one" ], +0x6a : [ 1, "inp 2", "one" ], +0x6b : [ 1, "inp 3", "one" ], +0x6c : [ 1, "inp 4", "one" ], +0x6d : [ 1, "inp 5", "one" ], +0x6e : [ 1, "inp 6", "one" ], +0x6f : [ 1, "inp 7", "one" ], + +0x70 : [ 1, "ret", "one" ], +0x71 : [ 1, "dis", "one" ], +0x72 : [ 1, "ldxa", "one" ], +0x73 : [ 1, "stxd", "one" ], +0x74 : [ 1, "adc", "one" ], +0x75 : [ 1, "sdb", "one" ], +0x76 : [ 1, "rshr", "one" ], +0x77 : [ 1, "smb", "one" ], +0x78 : [ 1, "sav", "one" ], +0x79 : [ 1, "mark", "one" ], +0x7a : [ 1, "req", "one" ], +0x7b : [ 1, "seq", "one" ], +0x7c : [ 1, "adci", "one" ], +0x7d : [ 1, "sdbi", "one" ], +0x7e : [ 1, "rshl", "one" ], +0x7f : [ 1, "smbi", "one" ], + +0x80 : [ 1, "glo", "one" ], +0x81 : [ 1, "glo", "one" ], +0x82 : [ 1, "glo", "one" ], +0x83 : [ 1, "glo", "one" ], +0x84 : [ 1, "glo", "one" ], +0x85 : [ 1, "glo", "one" ], +0x86 : [ 1, "glo", "one" ], +0x87 : [ 1, "glo", "one" ], +0x88 : [ 1, "glo", "one" ], +0x89 : [ 1, "glo", "one" ], +0x8a : [ 1, "glo", "one" ], +0x8b : [ 1, "glo", "one" ], +0x8c : [ 1, "glo", "one" ], +0x8d : [ 1, "glo", "one" ], +0x8e : [ 1, "glo", "one" ], +0x8f : [ 1, "glo", "one" ], + +0x90 : [ 1, "ghi 0", "one" ], +0x91 : [ 1, "ghi 1", "one" ], +0x92 : [ 1, "ghi 2", "one" ], +0x93 : [ 1, "ghi 3", "one" ], +0x94 : [ 1, "ghi 4", "one" ], +0x95 : [ 1, "ghi 5", "one" ], +0x96 : [ 1, "ghi 6", "one" ], +0x97 : [ 1, "ghi 7", "one" ], +0x98 : [ 1, "ghi 8", "one" ], +0x99 : [ 1, "ghi 9", "one" ], +0x9a : [ 1, "ghi 10", "one" ], +0x9b : [ 1, "ghi 11", "one" ], +0x9c : [ 1, "ghi 12", "one" ], +0x9d : [ 1, "ghi 13", "one" ], +0x9e : [ 1, "ghi 14", "one" ], +0x9f : [ 1, "ghi 15", "one" ], + +0xa0 : [ 1, "plo 0", "one" ], +0xa1 : [ 1, "plo 1", "one" ], +0xa2 : [ 1, "plo 2", "one" ], +0xa3 : [ 1, "plo 3", "one" ], +0xa4 : [ 1, "plo 4", "one" ], +0xa5 : [ 1, "plo 5", "one" ], +0xa6 : [ 1, "plo 6", "one" ], +0xa7 : [ 1, "plo 7", "one" ], +0xa8 : [ 1, "plo 8", "one" ], +0xa9 : [ 1, "plo 9", "one" ], +0xaa : [ 1, "plo 10", "one" ], +0xab : [ 1, "plo 11", "one" ], +0xac : [ 1, "plo 12", "one" ], +0xad : [ 1, "plo 13", "one" ], +0xae : [ 1, "plo 14", "one" ], +0xaf : [ 1, "plo 15", "one" ], + +0xb0 : [ 1, "phi 0", "one" ], +0xb1 : [ 1, "phi 1", "one" ], +0xb2 : [ 1, "phi 2", "one" ], +0xb3 : [ 1, "phi 3", "one" ], +0xb4 : [ 1, "phi 4", "one" ], +0xb5 : [ 1, "phi 5", "one" ], +0xb6 : [ 1, "phi 6", "one" ], +0xb7 : [ 1, "phi 7", "one" ], +0xb8 : [ 1, "phi 8", "one" ], +0xb9 : [ 1, "phi 9", "one" ], +0xba : [ 1, "phi 10", "one" ], +0xbb : [ 1, "phi 11", "one" ], +0xbc : [ 1, "phi 12", "one" ], +0xbd : [ 1, "phi 13", "one" ], +0xbe : [ 1, "phi 14", "one" ], +0xbf : [ 1, "phi 15", "one" ], + +0xc0 : [ 3, "lbr", "three" ], +0xc1 : [ 3, "lbq", "one" ], +0xc2 : [ 3, "lbz", "one" ], +0xc3 : [ 3, "lbdf", "one" ], +0xc4 : [ 1, "nop", "one" ], +0xc5 : [ 3, "lsnq", "one" ], +0xc6 : [ 3, "lsnz", "one" ], +0xc7 : [ 3, "lsnf", "one" ], +0xc8 : [ 3, "lskp", "one" ], +0xc9 : [ 3, "lbnq", "one" ], +0xca : [ 3, "lbnz", "three" ], +0xcb : [ 3, "lbnf", "three" ], +0xcc : [ 3, "lsie", "one" ], +0xcd : [ 3, "lsq", "one" ], +0xce : [ 3, "lsz", "one" ], +0xcf : [ 3, "lsdf", "one" ], + +0xd0 : [ 1, "sep", "one" ], +0xd1 : [ 1, "sep", "one" ], +0xd2 : [ 1, "sep", "one" ], +0xd3 : [ 1, "sep", "one" ], +0xd4 : [ 1, "sep", "one" ], +0xd5 : [ 1, "sep", "one" ], +0xd6 : [ 1, "sep", "one" ], +0xd7 : [ 1, "sep", "one" ], +0xd8 : [ 1, "sep", "one" ], +0xd9 : [ 1, "sep", "one" ], +0xda : [ 1, "sep", "one" ], +0xdb : [ 1, "sep", "one" ], +0xdc : [ 1, "sep", "one" ], +0xdd : [ 1, "sep", "one" ], +0xde : [ 1, "sep", "one" ], +0xdf : [ 1, "sep", "one" ], + +0xe0 : [ 1, "sex 0", "one" ], +0xe1 : [ 1, "sex 1", "one" ], +0xe2 : [ 1, "sex 2", "one" ], +0xe3 : [ 1, "sex 3", "one" ], +0xe4 : [ 1, "sex 4", "one" ], +0xe5 : [ 1, "sex 5", "one" ], +0xe6 : [ 1, "sex 6", "one" ], +0xe7 : [ 1, "sex 7", "one" ], +0xe8 : [ 1, "sex 8", "one" ], +0xe9 : [ 1, "sex 9", "one" ], +0xea : [ 1, "sex 10", "one" ], +0xeb : [ 1, "sex 11", "one" ], +0xec : [ 1, "sex 12", "one" ], +0xed : [ 1, "sex 13", "one" ], +0xee : [ 1, "sex 14", "one" ], +0xef : [ 1, "sex 15", "one" ], + +0xf0 : [ 1, "ldx", "one" ], +0xf1 : [ 1, "oe", "one" ], +0xf2 : [ 1, "and", "one" ], +0xf3 : [ 1, "xor", "one" ], +0xf4 : [ 1, "add", "one" ], +0xf5 : [ 1, "sd", "one" ], +0xf6 : [ 1, "shr", "one" ], +0xf7 : [ 1, "sm", "one" ], +0xf8 : [ 2, "ldi", "two" ], +0xf9 : [ 1, "ori", "one" ], +0xfa : [ 1, "ani", "one" ], +0xfb : [ 1, "xri", "one" ], +0xfc : [ 1, "adi", "one" ], +0xfd : [ 1, "sdi", "one" ], +0xfe : [ 1, "shl", "one" ], +0xff : [ 1, "smi", "one" ], + +} + +# End of processor specific code +########################################################################## diff --git a/README.md b/README.md index 556ae04..3d56ceb 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Z80 done F8 possible -1802 possible +1802 done TMS9900 possible diff --git a/udis.py b/udis.py index 2105004..a77ad88 100755 --- a/udis.py +++ b/udis.py @@ -57,7 +57,7 @@ try: exec(open(plugin).read()) except FileNotFoundError: print(("error: CPU plugin file '{}' not found.".format(plugin)), file=sys.stderr) - print("The following CPUs are supported: 6502 65816 65c02 6800 6809 6811 8051 8080 8085 z80") + print("The following CPUs are supported: 1802 6502 65816 65c02 6800 6809 6811 8051 8080 8085 z80") sys.exit(1) # Get filename from command line arguments.