-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathana.cpp
580 lines (537 loc) · 23.4 KB
/
ana.cpp
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
#include "m65816.hpp"
#define DI(itype, len, addr_mode, cpus) { (itype), (addr_mode), (cpus) },
#define DV(itype, len, addr_mode, cpus, flags) { (itype), (addr_mode), (cpus), (flags) },
static const struct opcode_info_t opinfos[] =
{
// 0x00
DI(M65816_brk, 2, STACK_INT , M6X )
DI(M65816_ora, 2, DP_IX_INDIR , M6X )
DI(M65816_cop, 2, STACK_INT , M65816 )
DI(M65816_ora, 2, STACK_REL , M65816 )
DI(M65816_tsb, 2, DP , M65C02 | M65816 )
DI(M65816_ora, 2, DP , M6X)
DI(M65816_asl, 2, DP , M6X)
DI(M65816_ora, 2, DP_INDIR_LONG , M6X)
// 0x08
DI(M65816_php, 1, STACK_PUSH , M6X )
DV(M65816_ora, 2, IMM , M6X , ACC16_INCBC)
DI(M65816_asl, 1, ACC , M6X )
DI(M65816_phd, 1, STACK_PUSH , M65816 )
DI(M65816_tsb, 3, ABS , M65C02 | M65816 )
DI(M65816_ora, 3, ABS , M6X )
DI(M65816_asl, 3, ABS , M6X )
DI(M65816_ora, 4, ABS_LONG , M65816 )
// 0x10
DI(M65816_bpl, 2, PC_REL , M6X )
DI(M65816_ora, 2, DP_INDIR_IY , M6X )
DI(M65816_ora, 2, DP_INDIR , M65C02 | M65816 )
DI(M65816_ora, 2, STACK_REL_INDIR_IY , M65816 )
DI(M65816_trb, 2, DP , M65C02 | M65816 )
DI(M65816_ora, 2, DP_IX , M6X )
DI(M65816_asl, 2, DP_IX , M6X )
DI(M65816_ora, 2, DP_INDIR_LONG_IY , M65816 )
// 0x18
DI(M65816_clc, 1, IMPLIED , M6X )
DI(M65816_ora, 3, ABS_IY , M6X )
DI(M65816_inc, 1, ACC , M65C02 | M65816 )
DI(M65816_tcs, 1, IMPLIED , M65816 )
DI(M65816_trb, 3, ABS , M65C02 | M65816 )
DI(M65816_ora, 3, ABS_IX , M6X )
DI(M65816_asl, 3, ABS_IX , M6X )
DI(M65816_ora, 4, ABS_LONG_IX , M65816 )
// 0x20
DI(M65816_jsr, 3, ABS , M6X )
DI(M65816_and, 2, DP_IX_INDIR , M6X )
DI(M65816_jsl, 4, ABS_LONG , M65816 )
DI(M65816_and, 2, STACK_REL , M65816 )
DI(M65816_bit, 2, DP , M6X )
DI(M65816_and, 2, DP , M6X )
DI(M65816_rol, 2, DP , M6X )
DI(M65816_and, 2, DP_INDIR_LONG , M65816 )
// 0x28
DI(M65816_plp, 1, STACK_PULL , M6X )
DV(M65816_and, 2, IMM , M6X , ACC16_INCBC)
DI(M65816_rol, 1, ACC , M6X )
DI(M65816_pld, 1, STACK_PULL , M65816 )
DI(M65816_bit, 3, ABS , M6X )
DI(M65816_and, 3, ABS , M6X )
DI(M65816_rol, 3, ABS , M6X )
DI(M65816_and, 4, ABS_LONG , M65816 )
// 0x30
DI(M65816_bmi, 2, PC_REL , M6X )
DI(M65816_and, 2, DP_INDIR_IY , M6X )
DI(M65816_and, 2, DP_INDIR , M65C02 | M65816 )
DI(M65816_and, 2, STACK_REL_INDIR_IY , M65816 )
DI(M65816_bit, 2, DP_IX , M65C02 | M65816 )
DI(M65816_and, 2, DP_IX , M6X )
DI(M65816_rol, 2, DP_IX , M6X )
DI(M65816_and, 2, DP_INDIR_LONG_IY , M65816 )
// 0x38
DI(M65816_sec, 1, IMPLIED , M6X )
DI(M65816_and, 3, ABS_IY , M6X )
DI(M65816_dec, 1, ACC , M65C02 | M65816 )
DI(M65816_tsc, 1, IMPLIED , M65816 )
DI(M65816_bit, 3, ABS_IX , M65C02 | M65816 )
DI(M65816_and, 3, ABS_IX , M6X )
DI(M65816_rol, 3, ABS_IX , M6X )
DI(M65816_and, 4, ABS_LONG_IX , M65816 )
// 0x40
DI(M65816_rti, 1, STACK_RTI , M6X )
DI(M65816_eor, 2, DP_IX_INDIR , M6X )
DI(M65816_wdm, 2, IMPLIED , M65816 )
DI(M65816_eor, 2, STACK_REL , M65816 )
DI(M65816_mvp, 3, BLK_MOV , M65816 )
DI(M65816_eor, 2, DP , M6X )
DI(M65816_lsr, 2, DP , M6X )
DI(M65816_eor, 2, DP_INDIR_LONG , M65816 )
// 0x48
DI(M65816_pha, 1, STACK_PUSH , M6X )
DV(M65816_eor, 2, IMM , M6X , ACC16_INCBC)
DI(M65816_lsr, 1, ACC , M6X )
DI(M65816_phk, 1, STACK_PUSH , M65816 )
DI(M65816_jmp, 3, ABS , M6X )
DI(M65816_eor, 3, ABS , M6X )
DI(M65816_lsr, 3, ABS , M6X )
DI(M65816_eor, 4, ABS_LONG , M65816 )
// 0x50
DI(M65816_bvc, 2, PC_REL , M6X )
DI(M65816_eor, 2, DP_INDIR_IY , M6X )
DI(M65816_eor, 2, DP_INDIR , M65C02 | M65816 )
DI(M65816_eor, 2, STACK_REL_INDIR_IY , M65816 )
DI(M65816_mvn, 3, BLK_MOV , M65816 )
DI(M65816_eor, 2, DP_IX , M6X )
DI(M65816_lsr, 2, DP_IX , M6X )
DI(M65816_eor, 2, DP_INDIR_LONG_IY , M65816 )
// 0x58
DI(M65816_cli, 1, IMPLIED , M6X )
DI(M65816_eor, 3, ABS_IY , M6X )
DI(M65816_phy, 1, STACK_PUSH , M65C02 | M65816 )
DI(M65816_tcd, 1, IMPLIED , M65816 )
DI(M65816_jml, 4, ABS_LONG , M65816 )
DI(M65816_eor, 3, ABS_IX , M6X )
DI(M65816_lsr, 3, ABS_IX , M6X )
DI(M65816_eor, 4, ABS_LONG_IX , M65816 )
// 0x60
DI(M65816_rts, 1, STACK_RTS , M6X )
DI(M65816_adc, 2, DP_IX_INDIR , M6X )
DI(M65816_per, 3, STACK_PC_REL , M65816 )
DI(M65816_adc, 2, STACK_REL , M65816 )
DI(M65816_stz, 2, DP , M65C02 | M65816 )
DI(M65816_adc, 2, DP , M6X )
DI(M65816_ror, 2, DP , M6X )
DI(M65816_adc, 2, DP_INDIR_LONG , M65816 )
// 0x68
DI(M65816_pla, 1, STACK_PULL , M6X )
DV(M65816_adc, 2, IMM , M6X , ACC16_INCBC)
DI(M65816_ror, 1, ACC , M6X )
DI(M65816_rtl, 1, STACK_RTL , M65816 )
DI(M65816_jmp, 3, ABS_INDIR , M6X )
DI(M65816_adc, 3, ABS , M6X )
DI(M65816_ror, 3, ABS , M6X )
DI(M65816_adc, 4, ABS_LONG , M65816 )
// 0x70
DI(M65816_bvs, 2, PC_REL , M6X )
DI(M65816_adc, 2, DP_INDIR_IY , M6X )
DI(M65816_adc, 2, DP_INDIR , M65C02 | M65816 )
DI(M65816_adc, 2, STACK_REL_INDIR_IY , M65816 )
DI(M65816_stz, 2, DP_IX , M65C02 | M65816 )
DI(M65816_adc, 2, DP_IX , M6X )
DI(M65816_ror, 2, DP_IX , M6X )
DI(M65816_adc, 2, DP_INDIR_LONG_IY , M65816 )
// 0x78
DI(M65816_sei, 1, IMPLIED , M6X )
DI(M65816_adc, 3, ABS_IY , M6X )
DI(M65816_ply, 1, STACK_PULL , M65C02 | M65816 )
DI(M65816_tdc, 1, IMPLIED , M65816 )
DI(M65816_jmp, 3, ABS_IX_INDIR , M65C02 | M65816 )
DI(M65816_adc, 3, ABS_IX , M6X )
DI(M65816_ror, 3, ABS_IX , M6X )
DI(M65816_adc, 4, ABS_LONG_IX , M6X )
// 0x80
DI(M65816_bra, 2, PC_REL , M65C02 | M65816 )
DI(M65816_sta, 2, DP_IX_INDIR , M6X )
DI(M65816_brl, 3, PC_REL_LONG , M65816 )
DI(M65816_sta, 2, STACK_REL , M65816 )
DI(M65816_sty, 2, DP , M6X )
DI(M65816_sta, 2, DP , M6X )
DI(M65816_stx, 2, DP , M6X )
DI(M65816_sta, 2, DP_INDIR_LONG , M65816 )
// 0x88
DI(M65816_dey, 1, IMPLIED , M6X )
DV(M65816_bit, 2, IMM , M65C02 | M65816 , ACC16_INCBC)
DI(M65816_txa, 1, IMPLIED , M6X )
DI(M65816_phb, 1, STACK_PUSH , M65816 )
DI(M65816_sty, 3, ABS , M6X )
DI(M65816_sta, 3, ABS , M6X )
DI(M65816_stx, 3, ABS , M6X )
DI(M65816_sta, 4, ABS_LONG , M65816 )
// 0x90
DI(M65816_bcc, 2, PC_REL , M6X )
DI(M65816_sta, 2, DP_INDIR_IY , M6X )
DI(M65816_sta, 2, DP_INDIR , M65C02 | M65816 )
DI(M65816_sta, 2, STACK_REL_INDIR_IY , M65816 )
DI(M65816_sty, 2, DP_IX , M6X )
DI(M65816_sta, 2, DP_IX , M6X )
DI(M65816_stx, 2, DP_IY , M6X )
DI(M65816_sta, 2, DP_INDIR_LONG_IY , M65816 )
// 0x98
DI(M65816_tya, 1, IMPLIED , M6X )
DI(M65816_sta, 3, ABS_IY , M6X )
DI(M65816_txs, 1, IMPLIED , M6X )
DI(M65816_txy, 1, IMPLIED , M65816 )
DI(M65816_stz, 3, ABS , M65C02 | M65816 )
DI(M65816_sta, 3, ABS_IX , M6X )
DI(M65816_stz, 3, ABS_IX , M65C02 | M65816 )
DI(M65816_sta, 4, ABS_LONG_IX , M65816 )
// 0xa0
DV(M65816_ldy, 2, IMM , M6X , XY16_INCBC)
DI(M65816_lda, 2, DP_IX_INDIR , M6X )
DV(M65816_ldx, 2, IMM , M6X , XY16_INCBC)
DI(M65816_lda, 2, STACK_REL , M65816 )
DI(M65816_ldy, 2, DP , M6X )
DI(M65816_lda, 2, DP , M6X )
DI(M65816_ldx, 2, DP , M6X )
DI(M65816_lda, 2, DP_INDIR_LONG , M65816 )
// 0xa8
DI(M65816_tay, 1, IMPLIED , M6X )
DV(M65816_lda, 2, IMM , M6X , ACC16_INCBC)
DI(M65816_tax, 1, IMPLIED , M6X )
DI(M65816_plb, 1, STACK_PULL , M65816 )
DI(M65816_ldy, 3, ABS , M6X )
DI(M65816_lda, 3, ABS , M6X )
DI(M65816_ldx, 3, ABS , M6X )
DI(M65816_lda, 4, ABS_LONG , M65816 )
// 0xb0
DI(M65816_bcs, 2, PC_REL , M6X )
DI(M65816_lda, 2, DP_INDIR_IY , M6X )
DI(M65816_lda, 2, DP_INDIR , M65C02 | M65816 )
DI(M65816_lda, 2, STACK_REL_INDIR_IY , M65816 )
DI(M65816_ldy, 2, DP_IX , M6X )
DI(M65816_lda, 2, DP_IX , M6X )
DI(M65816_ldx, 2, DP_IY , M6X )
DI(M65816_lda, 2, DP_INDIR_LONG_IY , M65816 )
// 0xb8
DI(M65816_clv, 1, IMPLIED , M6X )
DI(M65816_lda, 3, ABS_IY , M6X )
DI(M65816_tsx, 1, IMPLIED , M6X )
DI(M65816_tyx, 1, IMPLIED , M65816 )
DI(M65816_ldy, 3, ABS_IX , M6X )
DI(M65816_lda, 3, ABS_IX , M6X )
DI(M65816_ldx, 3, ABS_IY , M6X )
DI(M65816_lda, 4, ABS_LONG_IX , M65816 )
// 0xc0
DV(M65816_cpy, 2, IMM , M6X , XY16_INCBC)
DI(M65816_cmp, 2, DP_IX_INDIR , M6X )
DI(M65816_rep, 2, IMM , M65816 )
DI(M65816_cmp, 2, STACK_REL , M65816 )
DI(M65816_cpy, 2, DP , M6X )
DI(M65816_cmp, 2, DP , M6X )
DI(M65816_dec, 2, DP , M6X )
DI(M65816_cmp, 2, DP_INDIR_LONG , M65816 )
// 0xc8
DI(M65816_iny, 1, IMPLIED , M6X )
DV(M65816_cmp, 2, IMM , M6X , ACC16_INCBC)
DI(M65816_dex, 1, IMPLIED , M6X )
DI(M65816_wai, 1, IMPLIED , M65816 )
DI(M65816_cpy, 3, ABS , M6X )
DI(M65816_cmp, 3, ABS , M6X )
DI(M65816_dec, 3, ABS , M6X )
DI(M65816_cmp, 4, ABS_LONG , M65816 )
// 0xd0
DI(M65816_bne, 2, PC_REL , M6X )
DI(M65816_cmp, 2, DP_INDIR_IY , M6X )
DI(M65816_cmp, 2, DP_INDIR , M65C02 | M65816 )
DI(M65816_cmp, 2, STACK_REL_INDIR_IY , M65816 )
DI(M65816_pei, 2, STACK_DP_INDIR , M65816 )
DI(M65816_cmp, 2, DP_IX , M6X )
DI(M65816_dec, 2, DP_IX , M6X )
DI(M65816_cmp, 2, DP_INDIR_LONG_IY , M65816 )
// 0xd8
DI(M65816_cld, 1, IMPLIED , M6X )
DI(M65816_cmp, 3, ABS_IY , M6X )
DI(M65816_phx, 1, STACK_PUSH , M65C02 | M65816 )
DI(M65816_stp, 1, IMPLIED , M65816 )
DI(M65816_jmp, 3, ABS_INDIR_LONG , M65816 )
DI(M65816_cmp, 3, ABS_IX , M6X )
DI(M65816_dec, 3, ABS_IX , M6X )
DI(M65816_cmp, 4, ABS_LONG_IX , M65816 )
// 0xe0
DV(M65816_cpx, 2, IMM , M6X , XY16_INCBC)
DI(M65816_sbc, 2, DP_IX_INDIR , M6X )
DI(M65816_sep, 2, IMM , M65816 )
DI(M65816_sbc, 2, STACK_REL , M65816 )
DI(M65816_cpx, 2, DP , M6X )
DI(M65816_sbc, 2, DP , M6X )
DI(M65816_inc, 2, DP , M6X )
DI(M65816_sbc, 2, DP_INDIR_LONG , M65816 )
// 0xe8
DI(M65816_inx, 1, IMPLIED , M6X )
DV(M65816_sbc, 2, IMM , M6X , ACC16_INCBC)
DI(M65816_nop, 1, IMPLIED , M6X )
DI(M65816_xba, 1, IMPLIED , M65816 )
DI(M65816_cpx, 3, ABS , M6X )
DI(M65816_sbc, 3, ABS , M6X )
DI(M65816_inc, 3, ABS , M6X )
DI(M65816_sbc, 4, ABS_LONG , M65816 )
// 0xf0
DI(M65816_beq, 2, PC_REL , M6X )
DI(M65816_sbc, 2, DP_INDIR_IY , M6X )
DI(M65816_sbc, 2, DP_INDIR , M65C02 | M65816 )
DI(M65816_sbc, 2, STACK_REL_INDIR_IY , M65816 )
DI(M65816_pea, 3, STACK_ABS , M65816 )
DI(M65816_sbc, 2, DP_IX , M6X )
DI(M65816_inc, 2, DP_IX , M6X )
DI(M65816_sbc, 2, DP_INDIR_LONG_IY , M65816 )
// 0xf8
DI(M65816_sed, 1, IMPLIED , M6X )
DI(M65816_sbc, 3, ABS_IY , M6X )
DI(M65816_plx, 1, STACK_PULL , M65C02 | M65816 )
DI(M65816_xce, 1, IMPLIED , M65816 )
DI(M65816_jsr, 3, ABS_IX_INDIR , M65816 )
DI(M65816_sbc, 3, ABS_IX , M6X )
DI(M65816_inc, 3, ABS_IX , M6X )
DI(M65816_sbc, 4, ABS_LONG_IX , M65816 )
};
#undef DI
#undef DV
// ---------------------------------------------------------------------------
const struct opcode_info_t &get_opcode_info(uint8 opcode)
{
return opinfos[opcode];
}
// ---------------------------------------------------------------------------
inline bool is_acc_16_sensitive_op(const struct opcode_info_t &opinfo)
{
return (opinfo.flags & ACC16_INCBC) == ACC16_INCBC;
}
// ---------------------------------------------------------------------------
inline bool is_xy_16_sensitive_op(const struct opcode_info_t &opinfo)
{
return (opinfo.flags & XY16_INCBC) == XY16_INCBC;
}
// ---------------------------------------------------------------------------
int idaapi ana(void)
{
cmd.Op1.dtyp = dt_byte;
uint8 code = ua_next_byte();
// Fetch instruction info
const struct opcode_info_t &opinfo = get_opcode_info(code);
cmd.itype = opinfo.itype;
switch ( opinfo.addr )
{
case ACC:
case STACK_PUSH:
case STACK_PULL:
case STACK_RTS:
case STACK_RTI:
case STACK_RTL:
case IMPLIED:
break;
case STACK_INT:
// COP & BRK; they are 1-byte, but have
// another, signature byte.
ua_next_byte();
break;
case STACK_ABS:
// Always 16 bits
cmd.Op1.type = o_imm;
cmd.Op1.value = ua_next_word();
cmd.Op1.dtyp = dt_word;
break;
case STACK_REL:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = rS;
cmd.Op1.addr = ua_next_byte();
cmd.Op1.dtyp = dt_byte;
break;
case STACK_REL_INDIR_IY:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = rSiY;
cmd.Op1.addr = ua_next_byte();
cmd.Op1.dtyp = dt_byte;
break;
case STACK_PC_REL:
{
int16 disp = ua_next_word();
cmd.Op1.type = o_near;
cmd.Op1.addr = uint16(cmd.ip + cmd.size + disp);
cmd.Op1.dtyp = dt_word;
}
break;
case STACK_DP_INDIR:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = rSDi;
cmd.Op1.addr = ua_next_byte();
cmd.Op1.dtyp = dt_word;
break;
case IMM:
cmd.Op1.type = o_imm;
if ( (is_acc_16_sensitive_op (opinfo) && is_acc_16_bits ())
|| (is_xy_16_sensitive_op (opinfo) && is_xy_16_bits ()) ) //
{
cmd.Op1.value = ua_next_word();
cmd.Op1.dtyp = dt_word;
}
else
{
cmd.Op1.value = ua_next_byte();
cmd.Op1.dtyp = dt_byte;
}
break;
case ABS:
cmd.Op1.type = o_mem;
cmd.Op1.addr = ua_next_word();
cmd.Op1.dtyp = dt_word;
cmd.Op1.full_target_ea = cmd.Op1.addr;
if ( cmd.itype == M65816_jsr || cmd.itype == M65816_jmp )
{
cmd.Op1.type = o_near;
}
else if ( cmd.itype == M65816_stx || cmd.itype == M65816_sty
|| cmd.itype == M65816_ldx || cmd.itype == M65816_ldy
|| cmd.itype == M65816_cpx || cmd.itype == M65816_cpy )
{
cmd.Op1.dtyp = is_xy_16_bits() ? dt_word : dt_byte;
}
else
{
cmd.Op1.dtyp = is_acc_16_bits() ? dt_word : dt_byte;
}
break;
case ABS_LONG:
cmd.Op1.type = o_mem_far;
cmd.Op1.addr = ua_next_word();
cmd.Op1.addr|= ua_next_byte() << 16;
cmd.Op1.full_target_ea = cmd.Op1.addr;
if ( cmd.itype == M65816_jsl || cmd.itype == M65816_jml )
cmd.Op1.type = o_far;
else
cmd.Op1.dtyp = is_acc_16_bits() ? dt_word : dt_byte;
break;
case ABS_IX:
case ABS_IY:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = opinfo.addr == ABS_IX ? rAbsX : rAbsY;
cmd.Op1.addr = ua_next_word();
if ( cmd.itype == M65816_ldx || cmd.itype == M65816_ldy )
cmd.Op1.dtyp = is_xy_16_bits() ? dt_word : dt_byte;
else
cmd.Op1.dtyp = is_acc_16_bits() ? dt_word : dt_byte;
break;
case ABS_LONG_IX:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = rAbsLX;
cmd.Op1.addr = ua_next_word();
cmd.Op1.addr |= ua_next_byte() << 16;
cmd.Op1.dtyp = is_acc_16_bits() ? dt_word : dt_byte;
break;
case ABS_INDIR:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = rAbsi;
cmd.Op1.addr = ua_next_word();
cmd.Op1.dtyp = dt_word;
break;
case ABS_INDIR_LONG:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = rAbsiL;
cmd.Op1.addr = ua_next_word();
cmd.Op1.dtyp = dt_word;
break;
case ABS_IX_INDIR:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = rAbsXi;
cmd.Op1.addr = ua_next_word();
cmd.Op1.dtyp = dt_word;
break;
case DP:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = rD;
cmd.Op1.addr = ua_next_byte();
if ( cmd.itype == M65816_stx || cmd.itype == M65816_sty
|| cmd.itype == M65816_ldx || cmd.itype == M65816_ldy
|| cmd.itype == M65816_cpx || cmd.itype == M65816_cpy )
{
cmd.Op1.dtyp = is_xy_16_bits() ? dt_word : dt_byte;
}
else
{
cmd.Op1.dtyp = is_acc_16_bits() ? dt_word : dt_byte;
}
break;
case DP_IY:
case DP_IX:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = opinfo.addr == DP_IX ? rDX : rDY;
cmd.Op1.addr = ua_next_byte();
if ( cmd.itype == M65816_stx || cmd.itype == M65816_sty
|| cmd.itype == M65816_ldx || cmd.itype == M65816_ldy )
{
cmd.Op1.dtyp = is_xy_16_bits() ? dt_word : dt_byte;
}
else
{
cmd.Op1.dtyp = is_acc_16_bits() ? dt_word : dt_byte;
}
break;
case DP_IX_INDIR:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = riDX;
cmd.Op1.addr = ua_next_byte();
cmd.Op1.dtyp = is_acc_16_bits() ? dt_word : dt_byte;
break;
case DP_INDIR:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = rDi;
cmd.Op1.addr = ua_next_byte();
cmd.Op1.dtyp = is_acc_16_bits() ? dt_word : dt_byte;
break;
case DP_INDIR_LONG:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = rDiL;
cmd.Op1.addr = ua_next_byte();
cmd.Op1.dtyp = is_acc_16_bits() ? dt_word : dt_byte;
break;
case DP_INDIR_IY:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = rDiY;
cmd.Op1.addr = ua_next_byte();
cmd.Op1.dtyp = is_acc_16_bits() ? dt_word : dt_byte;
break;
case DP_INDIR_LONG_IY:
cmd.Op1.type = o_displ;
cmd.Op1.phrase = rDiLY;
cmd.Op1.addr = ua_next_byte();
cmd.Op1.dtyp = is_acc_16_bits() ? dt_word : dt_byte;
break;
case PC_REL:
cmd.Op1.type = o_near;
{
char x = ua_next_byte();
cmd.Op1.addr = uint16(cmd.ip + cmd.size + x);
cmd.Op1.full_target_ea = cmd.Op1.addr;
cmd.Op1.dtyp = dt_word;
}
break;
case PC_REL_LONG:
cmd.Op1.type = o_far;
{
int16 x = ua_next_word();
cmd.Op1.addr = uint16(cmd.ip + cmd.size + x) | (cmd.ea & 0xff0000);
cmd.Op1.full_target_ea = cmd.Op1.addr;
cmd.Op1.dtyp = dt_word;
}
break;
case BLK_MOV:
cmd.Op1.type = o_imm;
cmd.Op1.value = ua_next_byte();
cmd.Op1.dtyp = dt_byte;
cmd.Op2.type = o_imm;
cmd.Op2.value = ua_next_byte();
cmd.Op2.dtyp = dt_byte;
break;
default:
warning("ana: bad code 0x%x, @: 0x%a (IP=%a)", code, cmd.ea, cmd.ip);
return 0;
}
return cmd.size;
}