-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopcodes.txt
171 lines (145 loc) · 4.54 KB
/
opcodes.txt
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
Opcode Hex Params Addr Mode Description
;ADC
ADC 61 i+x zp Add value from zerop+X address
ADC 65 zp zp Add value at zp address
ADC 69 v # Add value to A register
ADC 6D a a Add value at address
ADC 71 i,y zp Load zp address, add y, then add value at result addr
;SBC
SBC E5 zp zp Subtract value at zp
SBC E9 v # Subtract value from A
SBC ED a a Subtract valule at address
SBC F1 i,y zp Load zp address, add y, then subtract value at result addr
;AND
AND 21 i+x zp AND value from zerop+X addr
AND 25 zp zp AND value at zp addr
AND 29 v # AND value with A register
AND 2D a a AND value at addr
AND 31 i,y zp Load zp address, add y, then add value at result addr
;ORA
ORA 01 i+x zp OR value from zerop+X address
ORA 05 zp zp OR value from zp
ORA 09 v # OR value with A register
ORA 0D a a OR value from address
ORA 11 i,y zp Load zp address, add y to that, then OR value at result addr
;EOR
ERO 45 zp zp XOR with value at zp
EOR 49 v # XOR value with A register
EOR 4D a a XOR with value at address
EOR 55 zp,x zp XOR with value at zp+x
EOR 59 a,y a XOR with value at addr+y
EOR 5D a,x a XOR with value at addr+x
EOR 51 i,y zp Load value at zp, add y, then XOR with value at that address
;Rotate (ROL/ROR)
ROL 26 zp zp Rotate left at zp
ROL 2A n n Rotate accumulator left
ROL 2E a a Rotate address left
ROR 66 zp zp Rotate right at zp
ROR 6A n n Rotate accumulator right
ROR 6E a a Rotate address right
;Shift
ASL 0A n # Shift A register left
LSR 4A n n Shift A register right
LSR 46 zp zp Shift value at zp right
LSR 4E a a Shift value at address right
;INC
INC E6 zp zp Increment value at zp
INC EE a a Increment value at address
INC F6 zp,x zp Increment value at zp+x
INC FE a,x a Increment valuat at address+x
;DEC
DEC C6 zp zp Increment value at zp
DEC CE a a Increment value at address
DEC D6 zp,x zp Increment value at zp+x
DEC DE a,x a Increment valuat at address+x
;BIT
BIT 24 zp zp Sets N and V flags to bits 7 and 6 of zp
BIT 2C a a Sets N and V flags to bits 7 and 6 of addr
;Branch
BPL 10 l r Jump to label if plus result
BMI 30 l r Jump to label if minus result
BVC 50 l r Jump to label on overflow clear
BVS 70 l r Jump to label on overflow set
BCC 90 l r Jump to label on carry clear
BCS B0 l r Jump to label on carry set
BNE D0 l r Jump to label if Z flag is 0
BEQ F0 l r Jump to label if Z flag is 1
;CMP
CMP C5 zp zp Compare with value at zp
CMP C9 v # Compare value to A register
CMP CD a a Compare with value at addr
;CPX
CPX E0 v # Compare X with value, Z=1 if equal
CPX E4 zp zp Compare X with value at zp
CPX EC a a Compare X with value at addr
;CPY
CPY C0 v # Compare Y to value
CPY C4 zp zp Compare Y with value at zp
CPY CC a a Compare Y with value at addr
;LDA
LDA A1 i+x zp Load value from zerop+X address into Y
LDA A5 zp zp Load value at zerop into A
LDA A9 v # Load value into A
LDA AD a a Load value at address into A
LDA B1 i,y zp Load address from zerop, add y to it, then load that addr into A
LDA B5 zp,x zp Load value at zp+X into A
LDA B9 a,y a Load value at address+y into A
LDA BD a,x a Load value at address+x into A
;LDX
LDX A2 v # Load value into X
LDX A6 zp zp Load value at zerop into X
LDX AE a a Load value at address
LDX B6 i,y zp Load value at zp, add y, then load that address
LDX BE a,y a Load value at address+Y
;LDY
LDY A0 v # Load value into Y
LDY A4 zp zp Load value at zerop into Y
LDY AC a a Load value at address
LDY B4 i,y zp Load value at zp, add y, then load that address
LDY BC a,y a Load value at address+Y
;Registers
DEY 88 n i Decrement Y
TXA 8A n i Transfer X to A
TYA 98 n i Transfer Y to A
TAY A8 n i Transfer A to Y
TAX AA n i Transfer A to X
INY C8 n i Increment Y
DEX CA n i Decrement X
INX E8 n i Increment X
;JMP
JMP 4C l a Jump to label
JMP 6C i a Jump to the address at the argument address.
JSR 20 l a Jump to subroutine (at label)
;Returns
RTI 40 n s Return from interrupt
RTS 60 n s Return from subroutine
;Stack
PHA 48 n s Push A to stack ($0100-$01FF, starting from FF)
PHP 08 n s Push status to the stack
PLP 28 n s Pull status from stack
PLA 68 n s Pull off stack to A
;Flags
CLC 18 n # Clear carry
SEC 38 n # Set carry
CLI 58 n # Clear interrupt
SEI 78 n # Set interrupt
CLV B8 n # Clear overflow
CLD D8 n # Clear decimal
SED F8 n # Set decimal
;STA
STA 85 zp zp Store A to zp
STA 8D a a Store A at address
STA 95 zp,x zp Store A to zp+x
STA 99 a,y a Store A in address+Y
STA 9D a,x a Store A in address+X
;STX
STX 86 zp zp Store X at zp
STX 8E a a Store X at address
STX 96 zp,y zp Store X t zp+y
;STY
STY 84 zp zp Store Y at zp
STY 8C a a Store Y at address
STY 94 zp,x zp Store Y at zp+x
;Misc
BRK 00 n s Halt
NOP EA n i No operation