Advertisement
Bisqwit

NES assembler data (from nescom)

Feb 14th, 2020
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.34 KB | None | 0 0
  1. const struct AddrMode
  2. {
  3.     char forbid;
  4.     const char *prereq;
  5.     const char *postreq;
  6.     enum { tNone, tByte, tWord, tRel8 } p1, p2;
  7. } AddrModes[] =
  8. {
  9.     /* Sorted in priority order - but the no-parameters-type must come first! */
  10.  
  11.   /* num  example      reject prereq postreq p1-type         p2-type */
  12.   { /* 0  nop          */   0, "",   "",   AddrMode::tNone, AddrMode::tNone },//o      AC,IL
  13.   { /* 1  rep #imm8    */   0, "#",  "",   AddrMode::tByte, AddrMode::tNone },//o #B   IM
  14.   { /* 2  bcc rel8     */   0, "",   "",   AddrMode::tRel8, AddrMode::tNone },//o r    RL
  15.   { /* 3  lda $10      */ '(', "",   "",   AddrMode::tByte, AddrMode::tNone },//o B    ZP
  16.   { /* 4  lda $10,x    */ '(', "",   ",x", AddrMode::tByte, AddrMode::tNone },//o B,x  ZX
  17.   { /* 5  lda $10,y    */ '(', "",   ",y", AddrMode::tByte, AddrMode::tNone },//o B,y  ZY
  18.   { /* 6  lda ($10,x)  */   0, "(", ",x)", AddrMode::tByte, AddrMode::tNone },//o (B,x) IX
  19.   { /* 7  lda ($10),y  */   0, "(", "),y", AddrMode::tByte, AddrMode::tNone },//o (B),y IY
  20.   { /* 8  lda $1234    */ '(', "",   "",   AddrMode::tWord, AddrMode::tNone },//o W    AB
  21.   { /* 9  lda $1234,x  */ '(', "",   ",x", AddrMode::tWord, AddrMode::tNone },//o W,x  AX
  22.   { /* 10 lda $1234,y  */ '(', "",   ",y", AddrMode::tWord, AddrMode::tNone },//o W,y  AY
  23.   { /* 11 lda ($1234)  */   0, "(",  ")",  AddrMode::tWord, AddrMode::tNone },//o (W)  IN
  24.   { /* 12 .link group 1  */ 0, "group", "",AddrMode::tWord, AddrMode::tNone },
  25.   { /* 13 .link page $FF */ 0, "page",  "",AddrMode::tByte, AddrMode::tNone },
  26.   { /* 14 .nop imm16  */    0, "",   "",   AddrMode::tWord, AddrMode::tNone }
  27. };
  28. const unsigned AddrModeCount = sizeof(AddrModes) / sizeof(AddrModes[0]);
  29.  
  30. const struct ins
  31. {
  32.     const char *token;
  33.     const char *opcodes;
  34.     bool operator< (const std::string &s) const { return s > token; }
  35. } ins[] =
  36. {
  37.     // IMPORTANT: Alphabetical sorting!
  38.  
  39.   { ".(",    "sb" }, // start block, no params
  40.   { ".)",    "eb" }, // end block, no params
  41.   { ".bss",  "gb" }, // Select seG BSS
  42.   { ".data", "gd" }, // Select seG DATA
  43.   { ".link",         // Select linkage (modes 12 and 13)
  44.            "--'--'--'--'--'--'--'--'--'--'--'--'li'li" },
  45.   { ".nop",          // Nop macro (mode 14)
  46.            "--'--'--'--'--'--'--'--'--'--'--'--'--'--'np" },
  47.   { ".text", "gt" }, // Select seG TEXT
  48.   { ".zero", "gz" }, // Select seG ZERO
  49.  
  50.   // ins     0  1  2  3  4  5  6  7  8  9 10 11
  51.   { "adc",  "--'69'--'65'75'--'61'71'6D'7D'79'--"},
  52.   { "anc0B","--'0B'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  53.   { "anc2B","--'2B'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  54.   { "and",  "--'29'--'25'35'--'21'31'2D'3D'39'--"},
  55.   { "ane",  "--'8B'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  56.   { "arr",  "--'6B'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  57.   { "asl",  "0A'--'--'06'16'--'--'--'0E'1E'--'--"},
  58.   { "asr",  "--'4B'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  59.   { "bcc",  "--'--'90'--'--'--'--'--'--'--'--'--"},
  60.   { "bcs",  "--'--'B0'--'--'--'--'--'--'--'--'--"},
  61.   { "beq",  "--'--'F0'--'--'--'--'--'--'--'--'--"},
  62.   { "bit",  "--'--'--'24'--'--'--'--'2C'--'--'--"},
  63.   { "bmi",  "--'--'30'--'--'--'--'--'--'--'--'--"},
  64.   { "bne",  "--'--'D0'--'--'--'--'--'--'--'--'--"},
  65.   { "bpl",  "--'--'10'--'--'--'--'--'--'--'--'--"},
  66.   { "brk",  "--'00'--'--'--'--'--'--'--'--'--'--"},
  67.   { "bvc",  "--'--'50'--'--'--'--'--'--'--'--'--"},
  68.   { "bvs",  "--'--'70'--'--'--'--'--'--'--'--'--"},
  69.   { "clc",  "18'--'--'--'--'--'--'--'--'--'--'--"},
  70.   { "cld",  "D8'--'--'--'--'--'--'--'--'--'--'--"},
  71.   { "cli",  "58'--'--'--'--'--'--'--'--'--'--'--"},
  72.   { "clv",  "B8'--'--'--'--'--'--'--'--'--'--'--"},
  73.   { "cmp",  "--'C9'--'C5'D5'--'C1'D1'CD'DD'D9'--"},
  74.   { "cpx",  "--'E0'--'E4'--'--'--'--'EC'--'--'--"},
  75.   { "cpy",  "--'C0'--'C4'--'--'--'--'CC'--'--'--"},
  76.   { "dcp",  "--'--'--'C7'D7'--'C3'D3'CF'DF'DB'--"}, // Unofficial instruction, combines DEC+CMP
  77.   { "dec",  "--'--'--'C6'D6'--'--'--'CE'DE'--'--"},
  78.   { "dex",  "CA'--'--'--'--'--'--'--'--'--'--'--"},
  79.   { "dey",  "88'--'--'--'--'--'--'--'--'--'--'--"},
  80.   { "eor",  "--'49'--'45'55'--'41'51'4D'5D'59'--"},
  81.   { "inc",  "--'--'--'E6'F6'--'--'--'EE'FE'--'--"}, // no "inc addr,y", but has "inc addr,x"
  82.   { "inx",  "E8'--'--'--'--'--'--'--'--'--'--'--"},
  83.   { "iny",  "C8'--'--'--'--'--'--'--'--'--'--'--"},
  84.   { "isb",  "--'--'--'E7'F7'--'E3'F3'EF'FF'FB'--"}, // Unofficial instruction, combines INC+SBC
  85.   { "jmp",  "--'--'--'--'--'--'--'--'4C'--'--'6C"},
  86.   { "jsr",  "--'--'--'--'--'--'--'--'20'--'--'--"},
  87.   { "kil02","--'02'--'--'--'--'--'12'--'--'--'--"}, // Unofficial instruction
  88.   { "kil22","--'22'--'--'--'--'--'32'--'--'--'--"}, // Unofficial instruction
  89.   { "kil42","--'42'--'--'--'--'--'52'--'--'--'--"}, // Unofficial instruction
  90.   { "kil62","--'62'--'--'--'--'--'72'--'--'--'--"}, // Unofficial instruction
  91.   { "kil92","--'--'--'--'--'--'--'92'--'--'--'--"}, // Unofficial instruction
  92.   { "kilB2","--'--'--'--'--'--'--'B2'--'--'--'--"}, // Unofficial instruction
  93.   { "kilD2","--'--'--'--'--'--'--'D2'--'--'--'--"}, // Unofficial instruction
  94.   { "kilF2","--'E2'--'--'--'--'--'F2'--'--'--'--"}, // Unofficial instruction
  95.   { "las",  "--'--'--'--'--'--'--'--'--'--'BB'--"}, // Unofficial instruction, combines LDA+LDX+TXS
  96.   { "lax",  "--'AB'--'A7'--'B7'A3'B3'AF'--'BF'--"}, // Unofficial instruction, combines LDA+LDX
  97.   { "lda",  "--'A9'--'A5'B5'--'A1'B1'AD'BD'B9'--"},
  98.   { "ldx",  "--'A2'--'A6'--'B6'--'--'AE'--'BE'--"}, // doesn't support "ldx addr,x"
  99.   { "ldy",  "--'A0'--'A4'B4'--'--'--'AC'BC'--'--"}, // doesn't support "ldy addr,y"
  100.   { "lsr",  "4A'--'--'46'56'--'--'--'4E'5E'--'--"},
  101.   { "nop",  "EA'--'--'--'--'--'--'--'--'--'--'--"},
  102.   { "nop04","--'--'--'04'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  103.   { "nop1A","1A'--'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  104.   { "nop14","--'--'--'--'14'--'--'--'0C'1C'--'--"}, // Unofficial instruction
  105.   { "nop3A","3A'--'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  106.   { "nop34","--'--'--'--'34'--'--'--'--'3C'--'--"}, // Unofficial instruction
  107.   { "nop44","--'--'--'44'54'--'--'--'--'--'--'--"}, // Unofficial instruction
  108.   { "nop5A","5A'--'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  109.   { "nop5C","--'--'--'--'--'--'--'--'--'5C'--'--"}, // Unofficial instruction
  110.   { "nop64","--'--'--'64'74'--'--'--'--'--'--'--"}, // Unofficial instruction
  111.   { "nop7A","7A'--'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  112.   { "nop7C","--'--'--'--'--'--'--'--'--'7C'--'--"}, // Unofficial instruction
  113.   { "nop80","--'80'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  114.   { "nop82","--'82'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  115.   { "nop89","--'89'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  116.   { "nopC2","--'C2'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  117.   { "nopDA","DA'--'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  118.   { "nopD4","--'--'--'--'D4'--'--'--'--'DC'--'--"}, // Unofficial instruction
  119.   { "nopE2","--'E2'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  120.   { "nopFA","FA'--'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  121.   { "nopF4","--'--'--'--'F4'--'--'--'--'FC'--'--"}, // Unofficial instruction
  122.   { "ora",  "--'09'--'05'15'--'01'11'0D'1D'19'--"},
  123.   { "pha",  "48'--'--'--'--'--'--'--'--'--'--'--"},
  124.   { "php",  "08'--'--'--'--'--'--'--'--'--'--'--"},
  125.   { "pla",  "68'--'--'--'--'--'--'--'--'--'--'--"},
  126.   { "plp",  "28'--'--'--'--'--'--'--'--'--'--'--"},
  127.   { "rla",  "--'--'--'27'37'--'23'33'2F'3F'3B'--"}, // Unofficial instruction, combines ROL+AND
  128.   { "rol",  "2A'--'--'26'36'--'--'--'2E'3E'--'--"},
  129.   { "ror",  "6A'--'--'66'76'--'--'--'6E'7E'--'--"},
  130.   { "rra",  "--'--'--'67'77'--'63'73'6F'7F'7B'--"}, // Unofficial instruction, combines ROR+ADC
  131.   { "rti",  "40'--'--'--'--'--'--'--'--'--'--'--"},
  132.   { "rts",  "60'--'--'--'--'--'--'--'--'--'--'--"},
  133.   { "sax",  "--'--'--'87'--'97'83'--'8F'--'--'--"}, // Unofficial instruction, stores A&X to memory
  134.   { "sbc",  "--'E9'--'E5'F5'--'E1'F1'ED'FD'F9'--"},
  135.   { "sbcEB","--'EB'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  136.   { "sbx",  "--'CB'--'--'--'--'--'--'--'--'--'--"}, // Unofficial instruction
  137.   { "sec",  "38'--'--'--'--'--'--'--'--'--'--'--"},
  138.   { "sed",  "F8'--'--'--'--'--'--'--'--'--'--'--"},
  139.   { "sei",  "78'--'--'--'--'--'--'--'--'--'--'--"},
  140.   { "sha",  "--'--'--'--'--'--'--'93'--'--'9F'--"}, // Unofficial instruction
  141.   { "shs",  "--'--'--'--'--'--'--'--'--'--'9B'--"}, // Unofficial instruction
  142.   { "shx",  "--'--'--'--'--'--'--'--'--'--'9E'--"}, // Unofficial instruction
  143.   { "shy",  "--'--'--'--'--'--'--'--'--'9C'--'--"}, // Unofficial instruction
  144.   { "slo",  "--'--'--'07'17'--'03'13'0F'1F'1B'--"}, // Unofficial instruction, combines ASL+ORA
  145.   { "sre",  "--'--'--'47'57'--'43'53'4F'5F'5B'--"}, // Unofficial instruction, combines LSR+EOR
  146.   { "sta",  "--'--'--'85'95'--'81'91'8D'9D'99'--"},
  147.   { "stx",  "--'--'--'86'--'96'--'--'8E'--'--'--"},
  148.   { "sty",  "--'--'--'84'94'--'--'--'8C'--'--'--"},
  149.   { "tax",  "AA'--'--'--'--'--'--'--'--'--'--'--"},
  150.   { "tay",  "A8'--'--'--'--'--'--'--'--'--'--'--"},
  151.   { "tsx",  "BA'--'--'--'--'--'--'--'--'--'--'--"},
  152.   { "txa",  "8A'--'--'--'--'--'--'--'--'--'--'--"},
  153.   { "txs",  "9A'--'--'--'--'--'--'--'--'--'--'--"},
  154.   { "tya",  "98'--'--'--'--'--'--'--'--'--'--'--"},
  155. };
  156. const unsigned InsCount = sizeof(ins) / sizeof(ins[0]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement