6 enum nes6502_instruction
{
7 INSN_AAC
= 0, /* [Undocumented]Logical "And" byte with accumulator. If result is negative then carry is set. */
8 INSN_AAX
, /* [Undocumented]Logical "And" X register with accumulator and store result in memory. (No flags changed) */
9 INSN_ADC
, /* Add Memory to Accumulator with Carry */
10 INSN_AND
, /* Logical "And" Memory with Accumulator */
11 INSN_ARR
, /* [Undocumented]Logical "And" byte with accumulator, then rotate one bit right in accumulator and check bit 5 and 6. */
12 INSN_ASL
, /* Shift Left One Bit (Memory or Accumulator) */
13 INSN_ASR
, /* [Undocumented]Logical "And" byte with accumulator, then shift right one bit in accumulator. */
14 INSN_ATX
, /* [Undocumented]Logical "And" byte with accumulator, then transfer accumulator to X register. Or it could be (A = X = ((A | 0xEE) & data)). Highly unpredictable.*/
15 INSN_AXA
, /* [Undocumented]Logical "And" X register with accumulator then AND result with (ADDR_HI + 1) and store in memory. Unpredictable. */
16 INSN_AXS
, /* [Undocumented]Logical "And" X register with accumulator and store result in X register, then subtract byte from X register (without borrow). (carry should work the same way as CMP) */
17 INSN_BCC
, /* Branch on Carry Clear */
18 INSN_BCS
, /* Branch on Carry Set */
19 INSN_BEQ
, /* Branch on Result Zero */
20 INSN_BIT
, /* Test Bits in Memory with Accumulator */
21 INSN_BMI
, /* Branch on Result Minus */
22 INSN_BNE
, /* Branch on Result not Zero */
23 INSN_BPL
, /* Branch on Result Plus */
24 INSN_BRK
, /* Force Break */
25 INSN_BVC
, /* Branch on Overflow Clear */
26 INSN_BVS
, /* Branch on Overflow Set */
27 INSN_CLC
, /* Clear Carry Flag */
28 INSN_CLD
, /* Clear Decimal Mode */
29 INSN_CLI
, /* Clear interrupt Disable Bit */
30 INSN_CLV
, /* Clear Overflow Flag */
31 INSN_CMP
, /* Compare Memory and Accumulator */
32 INSN_CPX
, /* Compare Memory and Index X */
33 INSN_CPY
, /* Compare Memory and Index Y */
34 INSN_DCP
, /* [Undocumented]Subtract 1 from memory (without borrow) and then compare with accumulator */
35 INSN_DEC
, /* Decrement Memory by One */
36 INSN_DEX
, /* Decrement Index X by One */
37 INSN_DEY
, /* Decrement Index Y by One */
38 INSN_DOP
, /* [Undocumented]Double NOP (fetches memory) */
39 INSN_EOR
, /* Logical "Exclusive-Or" Memory with Accumulator */
40 INSN_HLT
, /* [Undocumented] Halt (JAM) 6502. */
41 INSN_INC
, /* Increment Memory by One */
42 INSN_INX
, /* Increment Index X by One */
43 INSN_INY
, /* Increment Index Y by One */
44 INSN_ISC
, /* [Undocumented]Increase memory by one, then subtract memory from accumulator (with borrow) like SBC. */
45 INSN_JMP
, /* Jump to New Location */
46 INSN_JSR
, /* Jump to New Location Saving Return Address */
47 INSN_LAR
, /* [Undocumented]AND memory with stack pointer, transfer result to accumulator, X register and stack pointer. */
48 INSN_LAX
, /* [Undocumented]Load accumulator and X register with memory. */
49 INSN_LDA
, /* Load Accumulator with Memory */
50 INSN_LDX
, /* Load Index X with Memory */
51 INSN_LDY
, /* Load Index Y with Memory */
52 INSN_LSR
, /* Shift Right One Bit (Memory or Accumulator) */
53 INSN_NOP
, /* No Operation */
54 INSN_ORA
, /* Logical "Or" Memory with Accumulator */
55 INSN_PHA
, /* Push Accumulator on Stack */
56 INSN_PHP
, /* Push Processor Status on Stack */
57 INSN_PLA
, /* Pull Accumulator from Stack */
58 INSN_PLP
, /* Pull Processor Status from Stack */
59 INSN_RLA
, /* [Undocumented]Rotate one bit left in memory, then AND accumulator with memory. */
60 INSN_ROL
, /* Rotate One Bit Left (Memory or Accumulator) */
61 INSN_ROR
, /* Rotate One Bit Right (Memory or Accumulator) */
62 INSN_RRA
, /* [Undocumented]Rotate one bit right in memory, then add memory to accumulator (with carry). */
63 INSN_RTI
, /* Return from Interrupt */
64 INSN_RTS
, /* Return from Subroutine */
65 INSN_SBC
, /* Subtract Memory from Accumulator with Borrow */
66 INSN_SEC
, /* Set Carry Flag */
67 INSN_SED
, /* Set Decimal Mode */
68 INSN_SEI
, /* Set Interrupt Disable Status */
69 INSN_SLO
, /* [Undocumented]Shift left one bit in memory, then OR accumulator with memory. */
70 INSN_SRE
, /* [Undocumented]Shift right one bit in memory, then EOR accumulator with memory. */
71 INSN_STA
, /* Store Accumulator in Memory */
72 INSN_STX
, /* Store Index X in Memory */
73 INSN_STY
, /* Store Index Y in Memory */
74 INSN_SXA
, /* [Undocumented]AND X register with the high byte of the target address of the argument + 1. Store the result in memory. */
75 INSN_SYA
, /* [Undocumented]AND Y register with the high byte of the target address of the argument + 1. Store the result in memory. */
76 INSN_TAX
, /* Transfer Accumulator to Index X */
77 INSN_TAY
, /* Transfer Accumulator to Index Y */
78 INSN_TOP
, /* [Undocumented]Triple NOP */
79 INSN_TSX
, /* Transfer Stack Pointer to Index X */
80 INSN_TXA
, /* Transfer Index X to Accumulator */
81 INSN_TXS
, /* Transfer Index X to Stack Pointer */
82 INSN_TYA
, /* Transfer Index Y to Accumulator */
83 INSN_XAA
, /* [Undocumented]A = (A | #$EE) & X & #byte */
84 INSN_XAS
/* [Undocumented]AND X register with accumulator and store result in stack pointer, then
85 AND stack pointer with the high byte of the target address of the argument + 1. Store result in memory. */
88 /* For the "details" field of nes6502_instruction_detail */
89 #define I_RD 1 /* The instruction reads from memory */
90 #define I_WR 2 /* The instruction writes to memory */
91 #define I_JP 4 /* It is a jump/branch (or related) */
92 #define I_ST 8 /* This instruction access the stack */
93 #define I_UN 16 /* It is an undocumented instruction */
96 /* For the used/changed registers in nes6502_instruction_detail */
102 struct nes6502_instruction_detail
{
105 uint32 changed_registers
;
106 uint32 used_registers
;
107 uint32 changed_flags
;
112 enum nes6502_addressing_mode
{
113 ADDR_ACCUMULATOR
= 0,
128 struct nes6502_opcode
{
129 enum nes6502_addressing_mode addressing
;
130 enum nes6502_instruction instruction
;
135 extern struct nes6502_instruction_detail nes6502_instructions
[];
136 extern struct nes6502_opcode nes6502_opcodes
[];
137 extern int nes6502_addressing_length
[];
139 uint32
nes6502_disassemble (uint8
*mem
, uint32 offset
, int count
);
141 #endif /* __NES6502I_H */