summaryrefslogtreecommitdiff
path: root/opcode.h
blob: f634be3924a460518bc67c4a85cfe42bc0bd990a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#define OPNAME(opcode) [opcode] = #opcode /* Get name of Opcode, for dissambly. */
#define CPS 0x00 /* Clear Processor Status. */
#define ADC 0x01 /* ADd with Carry. */
#define PHP 0x08 /* PusH Processor status to stack. */
#define PHA 0x09 /* PusH Accumulator to stack. */
#define PHY 0x0A /* PusH Y register to stack. */
#define PAY 0x0B /* Push Accumulator, and Y register to stack. */
#define PHX 0x0C /* PusH X register to stack. */
#define PAX 0x0D /* Push Accumulator, and X register to stack. */
#define JMP 0x10 /* JuMP to memory location. */
#define SBC 0x11 /* SuBtract with Carry. */
#define PLP 0x18 /* PuLl Processor status from stack. */
#define PLA 0x19 /* PuLl Accumulator from stack. */
#define PLY 0x1A /* PuLl Y register from stack. */
#define PYA 0x1B /* Pull Y register, and Accumulator from stack. */
#define PLX 0x1C /* PuLl X register from stack. */
#define PXA 0x1D /* Pull X register, and Accumulator from stack. */
#define JSR 0x20 /* Jump to SubRoutine. */
#define AND 0x21 /* bitwise AND with accumulator. */
#define ANY 0x22 /* bitwise ANd with Y register.*/
#define AAY 0x23 /* bitwise And with Accumulator, and Y register. */
#define ANX 0x24 /* bitwise ANd with X register. */
#define AAX 0x25 /* bitwise And with Accumulator, and X register. */
#define STT 0x28 /* STart Threads. */
#define BPO 0x30 /* Branch if POsitive. */
#define ORA 0x31 /* bitwise OR with Accumulator. */
#define ORY 0x32 /* bitwise OR with Y register. */
#define OAY 0x33 /* bitwise Or with Accumulator, and Y register. */
#define ORX 0x34 /* bitwise OR with X register. */
#define OAX 0x35 /* bitwise Or with Accumulator, and X register. */
#define SEI 0x38 /* SEt Interupt flag. */
#define BNG 0x40 /* Branch if NeGative. */
#define XOR 0x41 /* bitwise XOR with accumulator. */
#define XRY 0x42 /* bitwise XoR with Y register. */
#define XAY 0x43 /* bitwise Xor with Accumulator, and Y register. */
#define XRX 0x44 /* bitwise XoR with X register. */
#define XAX 0x45 /* bitwise Xor with Accumulator, and X register. */
#define CLI 0x48 /* CLear Interupt flag. */
#define BCS 0x50 /* Branch if Carry Set. */
#define SLA 0x51 /* Shift Left with Accumulator. */
#define SEC 0x58 /* SEt Carry flag. */
#define BCC 0x60 /* Branch if Carry Clear. */
#define SRA 0x61 /* Shift Right with Accumulator. */
#define CLC 0x68 /* CLear Carry flag. */
#define BEQ 0x70 /* Branch if EQual. */
#define ROL 0x71 /* ROtate Left. */
#define SSP 0x78 /* Set Stack Protection flag. */
#define BNE 0x80 /* Branch if Not Equal. */
#define ROR 0x81 /* ROtate Right. */
#define CSP 0x88 /* Clear Stack Protection flag. */
#define BVS 0x90 /* Branch if oVerflow Set. */
#define MUL 0x91 /* MULtiply with accumulator. */
#define SEV 0x98 /* SEt oVerflow flag. */
#define BVC 0xA0 /* Branch if oVerflow Clear. */
#define DIV 0xA1 /* DIVide with accumulator. */
#define CLV 0xA8 /* CLear oVerflow flag. */
#define RTS 0xB0 /* ReTurn from Subroutine. */
#define CMP 0xB1 /* CoMPare accumulator. */
#define CPY 0xB2 /* ComPare Y register. */
#define CAY 0xB3 /* Compare Accumulator, and Y register. */
#define CPX 0xB4 /* ComPare X register. */
#define CAX 0xB5 /* Compare Accumulator, and X register. */
#define ENT 0xB8 /* ENd Threads. */
#define RTI 0xC0 /* ReTurn from Interupt. */
#define INC 0xC1 /* INCrement accumulator. */
#define INY 0xC2 /* INcrement Y register. */
#define IAY 0xC3 /* Increment Accumulator, and Y register. */
#define INX 0xC4 /* INcrement X register. */
#define IAX 0xC5 /* Increment Accumulator, and X register. */
#define DEC 0xD1 /* DECrement accumulator. */
#define DEY 0xD2 /* DEcrement Y register. */
#define DAY 0xD3 /* Decrement Accumulator, and Y register. */
#define DEX 0xD4 /* DEcrement X register. */
#define DAX 0xD5 /* Decrement Accumulator, and X register. */
#define LDA 0xE1 /* LoaD Accumulator. */
#define LDY 0xE2 /* LoaD Y register. */
#define LAY 0xE3 /* Load Accumulator, and Y register. */
#define LDX 0xE4 /* LoaD X register. */
#define LAX 0xE5 /* Load Accumulator, and X register. */
#define NOP 0xE8 /* No OPeration. */
#define STA 0xF1 /* STore Accumulator. */
#define STY 0xF2 /* STore Y register. */
#define SAY 0xF3 /* Store Accumulator, and Y register. */
#define STX 0xF4 /* STore X register. */
#define SAX 0xF5 /* Store Accumulator, and X register. */
#define BRK 0xF8 /* BReaK. */
#define STP 0xFF /* SToP. */

enum {ALU, THREAD, BRANCH, FLAG, MEMORY, MISC};

static const char *opname[0x100] = {
	OPNAME(CPS),
	OPNAME(ADC),
	OPNAME(PHP),
	OPNAME(PHA),
	OPNAME(PHY),
	OPNAME(PAY),
	OPNAME(PHX),
	OPNAME(PAX),
	OPNAME(JMP),
	OPNAME(SBC),
	OPNAME(PLP),
	OPNAME(PLA),
	OPNAME(PLY),
	OPNAME(PYA),
	OPNAME(PLX),
	OPNAME(PXA),
	OPNAME(JSR),
	OPNAME(AND),
	OPNAME(ANY),
	OPNAME(AAY),
	OPNAME(ANX),
	OPNAME(AAX),
	OPNAME(STT),
	OPNAME(BPO),
	OPNAME(ORA),
	OPNAME(ORY),
	OPNAME(OAY),
	OPNAME(ORX),
	OPNAME(OAX),
	OPNAME(SEI),
	OPNAME(BNG),
	OPNAME(XOR),
	OPNAME(XRY),
	OPNAME(XAY),
	OPNAME(XRX),
	OPNAME(XAX),
	OPNAME(CLI),
	OPNAME(BCS),
	OPNAME(SLA),
	OPNAME(SEC),
	OPNAME(BCC),
	OPNAME(SRA),
	OPNAME(CLC),
	OPNAME(BEQ),
	OPNAME(ROL),
	OPNAME(SSP),
	OPNAME(BNE),
	OPNAME(ROR),
	OPNAME(CSP),
	OPNAME(BVS),
	OPNAME(MUL),
	OPNAME(SEV),
	OPNAME(BVC),
	OPNAME(DIV),
	OPNAME(CLV),
	OPNAME(RTS),
	OPNAME(CMP),
	OPNAME(CPY),
	OPNAME(CAY),
	OPNAME(CPX),
	OPNAME(CAX),
	OPNAME(ENT),
	OPNAME(RTI),
	OPNAME(INC),
	OPNAME(INY),
	OPNAME(IAY),
	OPNAME(INX),
	OPNAME(IAX),
	OPNAME(DEC),
	OPNAME(DEY),
	OPNAME(DAY),
	OPNAME(DEX),
	OPNAME(DAX),
	OPNAME(LDA),
	OPNAME(LDY),
	OPNAME(LAY),
	OPNAME(LDX),
	OPNAME(LAX),
	OPNAME(NOP),
	OPNAME(STA),
	OPNAME(STY),
	OPNAME(SAY),
	OPNAME(STX),
	OPNAME(SAX),
	OPNAME(BRK),
	OPNAME(STP),
};