Debian Codegraph @

test/suite68hc908.asm

raw
1 ;
2 ; regression test for all opcodes for 68hc908 controller
3 ;
4 ; two opcodes with indirect X adressing and zero offset are not cleanly supported
5 ; dbnz (X), jumpLabel
6 ; cbeq (X), jumpLabel
7 ;
8 ; one must add forced-address-mode extension ".ix" to the mnemonic and add a dummy variable
9 ; in order to get the correct opcodes
10 ; dbnz.ix 0, jumpLabel
11 ; cbeq.ix 0, jumpLabel
12 ;
13
14 .PROCESSOR 68hc908
15
16 PTB .EQU 1
17 PTC .EQU 2
18 DDRB .EQU 5
19
20 FIVE .EQU 5
21 FIVE_HUNDRED .EQU 500
22
23 RAM_START .EQU 0x40
24
25 .ORG 0xFB00
26
27 .byte 0xba,0xdc,0x0d,0xe0
28
29 adc #6
30 adc RAM_START
31 adc [X+7]
32 adc constant0
33 adc [X+0x300]
34 adc ,X
35 adc [SP+5]
36 adc [SP+500]
37
38 add #6
39 add RAM_START
40 add 7,X
41 add constant0
42 add 0x300,X
43 add ,X
44 add FIVE,SP
45 add [SP+FIVE_HUNDRED]
46
47 aiS #5
48 aiX #6
49
50 and #6
51 and RAM_START
52 and 7,X
53 and constant0
54 and [X+0x300]
55 and ,X
56 and 5,SP
57 and FIVE_HUNDRED,SP
58
59 asl RAM_START
60 asl 3,X
61 asl ,X
62 asl 5,SP
63 aslA
64 aslX
65
66 asr RAM_START
67 asr 3,X
68 asr ,X
69 asr 5,SP
70 asrA
71 asrX
72
73 bcc frontLoop
74 bcs frontLoop
75 beq frontLoop
76 bhcc frontLoop
77 bhcs frontLoop
78 bhi frontLoop
79 bhs frontLoop
80 bih frontLoop
81 bil frontLoop
82
83 bit #6
84 bit RAM_START
85 bit 7,X
86 bit constant0
87 bit 0x300,X
88 bit ,X
89 bit 5,SP
90 bit 500,SP
91
92 blo frontLoop
93 bls frontLoop
94 bmc frontLoop
95 bmi frontLoop
96 bms frontLoop
97 bne frontLoop
98 bpl frontLoop
99 bra frontLoop
100 brn frontLoop
101
102 subRoutine:
103 rts
104
105 brset 0,PTB,frontLoop
106 brclr 0,PTC,subRoutine
107 brset 1,PTB,frontLoop
108 brclr 1,PTC,subRoutine
109 brset 2,PTB,frontLoop
110 brclr 2,PTC,subRoutine
111 brset 3,PTB,frontLoop
112 brclr 3,PTC,subRoutine
113 brset 4,PTB,frontLoop
114 brclr 4,PTC,subRoutine
115 brset 5,PTB,frontLoop
116 brclr 5,PTC,subRoutine
117 brset 6,PTB,frontLoop
118 brclr 6,PTC,subRoutine
119 brset 7,PTB,frontLoop
120 brclr 7,PTC,subRoutine
121
122 frontLoop:
123
124 bset 0,PTB
125 bclr 0,PTC
126 bset 1,PTB
127 bclr 1,PTC
128 bset 2,PTB
129 bclr 2,PTC
130 bset 3,PTB
131 bclr 3,PTC
132 bset 4,PTB
133 bclr 4,PTC
134 bset 5,PTB
135 bclr 5,PTC
136 bset 6,PTB
137 bclr 6,PTC
138 bset 7,PTB
139 bclr 7,PTC
140
141 bsr subRoutine
142
143 cbeqA $20,frontLoop
144 cbeq 9,frontLoop
145 cbeq (0xA,X), frontLoop
146 cbeq [SP+0x0B],frontLoop
147 cbeq.ix 0, frontLoop ; must add forced-address-mode extension to get opcode 0x71
148 cbeqX 0x40,frontLoop
149
150 clc
151 cli
152 ;frontLoop:
153
154 clr RAM_START
155 clr 3,X
156 clr ,X
157 clr 5,SP
158 clrA
159 clrH
160 clrX
161
162 cmp #6
163 cmp RAM_START
164 cmp 7,X
165 cmp constant0
166 cmp 0x300,X
167 cmp ,X
168 cmp 5,SP
169 cmp 500,SP
170
171 com RAM_START
172 com 3,X
173 com ,X
174 com 5,SP
175 comA
176 comX
177
178 cpHX RAM_START
179 cpHX #constant0
180
181 cpX #6
182 cpX RAM_START
183 cpX 7,X
184 cpX constant0
185 cpX 0x300,X
186 cpX ,X
187 cpX 5,SP
188 cpX FIVE_HUNDRED,SP
189
190 daa ; decimal adjust after BCD calculation
191
192 backLoop:
193 dbnzA backLoop
194 dbnz 4,backLoop
195 dbnz [X+5],backLoop
196 dbnz [SP+6],backLoop
197 dbnz.ix 0,backLoop ; must add forced-address-mode extension and dummy 0 to get opcode 0x7B
198 dbnzX backLoop
199
200 dec RAM_START
201 dec 3,X
202 dec ,X
203 dec 5,SP
204 decA
205 decX
206
207 div
208
209 mul
210 nsa
211 ble backLoop
212 bgt backLoop
213 blt backLoop
214 bge backLoop
215 wait
216 stop
217
218 eor #6
219 eor RAM_START
220 eor 7,X
221 eor constant0
222 eor 0x300,X
223 eor ,X
224 eor 5,SP
225 eor 500,SP
226
227 inc RAM_START
228 inc 3,X
229 inc ,X
230 inc 5,SP
231 incA
232 incX
233
234 jmp RAM_START
235 jmp vector0
236 jmp 3,X
237 jmp $300,X
238 jmp ,X
239
240 jsr RAM_START
241 jsr vector0
242 jsr 3,X
243 jsr 0x300,X
244 jsr ,X
245
246 ldA #6
247 ldA RAM_START
248 ldA 7,X
249 ldA constant0
250 ldA 0x300,X
251 ldA ,X
252 ldA 5,SP
253 ldA 500,SP
254
255 ldHX #500
256 ldHX RAM_START
257
258 ldX #55
259 ldX RAM_START
260 ldX 7,X
261 ldX constant0
262 ldX 0x300,X
263 ldX ,X
264 ldX 5,SP
265 ldX 500,SP
266
267 lsl RAM_START
268 lsl 3,X
269 lsl ,X
270 lsl 5,SP
271 lslA
272 lslX
273
274 lsr RAM_START
275 lsr 3,X
276 lsr ,X
277 lsr 5,SP
278 lsrA
279 lsrX
280
281
282 mov #5, RAM_START
283 movp RAM_START,X
284 mov 10, RAM_START
285 xmov RAM_START
286
287 neg RAM_START
288 neg 3,X
289 neg ,X
290 neg 5,SP
291 negA
292 negX
293
294 nop
295
296 orA #6
297 orA RAM_START
298 orA 7,X
299 orA constant0
300 orA 0x300,X
301 orA ,X
302 orA 5,SP
303 orA 500,SP
304
305 pshA
306 pshH
307 pshX
308 pulA
309 pulH
310 pulX
311
312 rol RAM_START
313 rol 3,X
314 rol ,X
315 rol 5,SP
316 rolA
317 rolX
318
319 ror RAM_START
320 ror 3,X
321 ror ,X
322 ror 5,SP
323 rorA
324 rorX
325
326 rsp
327
328 dummyISR:
329 rti
330
331 sbc #6
332 sbc RAM_START
333 sbc 7,X
334 sbc constant0
335 sbc 0x300,X
336 sbc ,X
337 sbc 5,SP
338 sbc 500,SP
339
340 sec
341 sei
342
343 stA RAM_START
344 stA 7,X
345 stA constant0
346 stA 0x300,X
347 stA ,X
348 stA 5,SP
349 stA 500,SP
350
351 stHX RAM_START
352
353 stX RAM_START
354 stX 7,X
355 stX constant0
356 stX 0x300,X
357 stX ,X
358 stX 5,SP
359 stX 500,SP
360
361 sub #6
362 sub RAM_START
363 sub 7,X
364 sub constant0
365 sub 0x300,X
366 sub ,X
367 sub 5,SP
368 sub 500,SP
369
370 swi
371 tAP
372 tAX
373 tHXS
374 tPA
375 tSHX
376
377 tst RAM_START
378 tst 3,X
379 tst ,X
380 tst 4,SP
381
382 tstA
383 tstX
384 tXA
385
386 ; .ORG 0xFE00
387 constant0:
388 .word 0
389 vector0:
390 .word dummyISR
391
392