blob: 0d566dbd637dd1af0862e8d584e0ef2ef14ab88d (
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
;; -*- mode: common-lisp -*-
;; 6502.lisp
;; Contains data structures specific to the 6502 system.
#|
clasm-6502: An assembler for the 6502 written in Common Lisp.
Copyright (C) 2024 Aleksei Eaves
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|#
;;; List of addressing modes and their length.
(defparameter
*addressing-mode-lengths*
'((immediate 2)
(absolute 3)
(zero-page 2)
(implied 1)
(indirect-absolute 3)
(absolute-indexed-x 3)
(absolute-indexed-y 3)
(zero-page-indexed-x 2)
(zero-page-indexed-y 2)
(indexed-indirect 2)
(indirect-indexed 2)
(relative 2)
(accumulator 1)))
;; Generated list of addressing modes.
(defparameter
*addressing-modes*
(extract-keys *addressing-mode-lengths*))
;;; Instructions, with decimal opcode and
;;; addressing modes.
(defparameter
*instructions*
;; Load & Store
'((LDA 169 (immediate
absolute
zero-page
absolute-indexed-x
absolute-indexed-y
zero-page-indexed-x
indexed-indirect
indirect-indexed))
(LDX 162 (immediate
zero-page
zero-page-indexed-y
absolute
absolute-indexed-y))
(LDY 160 (immediate
zero-page
zero-page-indexed-x
absolute
absolute-indexed-x))
(STA 137 (absolute
zero-page
absolute-indexed-x
absolute-indexed-y
zero-page-indexed-x
indexed-indirect
indirect-indexed))
(STX 130 (zero-page
zero-page-indexed-y
absolute))
(STY 128 (zero-page
zero-page-indexed-x
absolute))
;;Arithmetic
(ADC 105 (immediate
absolute
zero-page
absolute-indexed-x
absolute-indexed-y
zero-page-indexed-x
indexed-indirect
indirect-indexed))
(SBC 233 (immediate
absolute
zero-page
absolute-indexed-x
absolute-indexed-y
zero-page-indexed-x
indexed-indirect
indirect-indexed))
;;Increment & Decrement
(INC 226 (zero-page
zero-page-indexed-x
absolute
absolute-indexed-x))
(INX 232 (implied))
(INY 200 (implied))
(DEC 194 (zero-page
zero-page-indexed-x
absolute
absolute-indexed-x))
(DEX 202 (implied))
(DEY 136 (implied))
;; Logical
(AND 41 (immediate
absolute
zero-page
absolute-indexed-x
absolute-indexed-y
zero-page-indexed-x
indexed-indirect
indirect-indexed))
(ORA 9 (immediate
absolute
zero-page
absolute-indexed-x
absolute-indexed-y
zero-page-indexed-x
indexed-indirect
indirect-indexed))
(EOR 73 (immediate
absolute
zero-page
absolute-indexed-x
absolute-indexed-y
zero-page-indexed-x
indexed-indirect
indirect-indexed))
;; Jump, Branch, Compare
(JMP 72 (absolute
indirect-absolute))
(BCC 144 (relative))
(BCS 176 (relative))
(BEQ 240 (relative))
(BNE 208 (relative))
(BMI 48 (relative))
(BPL 16 (relative))
(BVS 112 (relative))
(BVC 80 (relative))
(CMP 201 (immediate
absolute
zero-page
absolute-indexed-x
absolute-indexed-y
zero-page-indexed-x
indexed-indirect
indirect-indexed))
(CPX 224 (immediate
zero-page
absolute))
(CPY 192 (immediate
zero-page
absolute))
(BIT 32 (zero-page
absolute))
;; Shift & Rotate
(ASL 10 (accumulator
zero-page
zero-page-indexed-x
absolute
absolute-indexed-x))
(LSR 74 (accumulator
zero-page
zero-page-indexed-x
absolute
absolute-indexed-x))
(ROL 42 (accumulator
zero-page
zero-page-indexed-x
absolute
absolute-indexed-x))
(ROR 106 (accumulator
zero-page
zero-page-indexed-x
absolute
absolute-indexed-x))
;; Transfer
(TAX 170 (implied))
(TAY 168 (implied))
(TXA 138 (implied))
(TYA 152 (implied))
;; Stack
(TSX 186 (implied))
(TXS 154 (implied))
(PHA 72 (implied))
(PHP 8 (implied))
(PLA 104 (implied))
(PLP 40 (implied))
;; Subroutine
(JSR 32 (implied))
(RTI 64 (implied))
(RTS 96 (implied))
;; Set & Reset
(CLC 24 (implied))
(CLD 216 (implied))
(CLI 88 (implied))
(CLV 184 (implied))
(SEC 56 (implied))
(SED 248 (implied))
(SEI 120 (implied))
;; Other
(NOP 234 (implied))
(BRK 0 (implied))))
;; Generated list of opcodes.
(defparameter
*opcodes*
(extract-keys *instructions*))
|