-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpCodes.X68
More file actions
1417 lines (1263 loc) · 47.2 KB
/
OpCodes.X68
File metadata and controls
1417 lines (1263 loc) · 47.2 KB
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
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*-----------------------------------------------------------
* Title : Op-Code Subroutines
* Written by : Brandon Authier (Hblkr), Jack S. Eldridge
* (JackScottie), Marijn Burger (marijnburger)
* Date : 3 May 2016
* Description: Support file containing the op-code subroutines
* for the disassembler.
*-----------------------------------------------------------
*----------- Subroutines: ----------------------------------
*----------- OC_PARSE --------------------------------------
OC_PARSE:
MOVEM.L A0-A1/A3-A5/D0-D7, -(SP) ; Save registers
LEA initial_table,A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #12,D1 ; Shift 12 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
initial_table:
JMP code0000 ; ADDI.B, ADDI.W, or ADDI.L
JMP code0001 ; MOVE.B
JMP code0010 ; MOVEA.L or MOVE.L
JMP code0011 ; MOVEA.W or MOVE.W
JMP code0100 ; NOP or MOVEM.W or MOVEM.L or LEA or CLR.B or CLR.W or CLR.L or JSR or RTS or MULS.W
JMP code0101 ; ADDQ.B or ADDQ.W or ADDQ.L
JMP code0110 ; BCC or BGT or BLE
JMP code0111 ; MOVEQ.L
JMP code1000 ; OR.B or OR.W or OR.L or DIVU (DIVU is either word or long depending on ea)
JMP code1001 ; SUB.B or SUB.W or SUB.L
JMP code1010
JMP code1011 ; CMP.B or CMP.W or CMP.L
JMP code1100 ; AND_BorAND_WorAND_LorMULS_W
JMP code1101 ; ADD.B or ADD.W or ADD.L
JMP code1110 ; ROd_LSd_ASd
JMP code1111
code0000 JSR ADDI_BorADDI_WorADDI_L
JMP DONE
code0001 JSR ISMOVEB
JMP DONE
code0010 JSR MOVEA_LorMOVE_L
JMP DONE
code0011 JSR MOVEA_WorMOVE_W
JMP DONE
code0100 JSR NOP_MOVEM_LEA_JSR_CLR_RTS
JMP DONE
code0101 JSR ADDQ_BorADDQ_WorADDQ_L
JMP DONE
code0110 JSR BCCorBGTorBLE
JMP DONE
code0111 JSR ISMOVEQL
JMP DONE
code1000 JSR OR_BorOR_WorOR_LorDIVU
JMP DONE
code1001 JSR SUB_BorSUB_WorSUB_L
JMP DONE
code1010 JSR OPCODE_INVALID ;INVALID
JMP DONE
code1011 JSR CMP_BorCMP_WorCMP_L
JMP DONE
code1100 JSR AND_BorAND_WorAND_LorMULS_W
JMP DONE
code1101 JSR ADD_BorADD_WorADD_L
JMP DONE
code1110 JSR ROd_LSd_ASd
JMP DONE
code1111 JSR OPCODE_INVALID ;INVALID
JMP DONE
*----------- Done ------------------------------------------
DONE MOVEM.L (SP)+, A0-A1/A3-A5/D0-D7 ; Restore registers
RTS
***************************** BCCorBGTorBLE ************************************
BCCorBGTorBLE LEA tableBCCorBGTorBLE, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #6,D1 ; Shift 6 bits left
LSL.W D1,D0
MOVE.B #14,D1 ; Shift 14 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableBCCorBGTorBLE JMP BCCorBGTorBLEcode00 ; BCC
JMP BCCorBGTorBLEcode01 ;
JMP BCCorBGTorBLEcode10 ; BGT
JMP BCCorBGTorBLEcode11 ; BLE
BCCorBGTorBLEcode00 JSR ISBCC
RTS
BCCorBGTorBLEcode01 JSR OPCODE_INVALID ;INVALID
RTS
BCCorBGTorBLEcode10 JSR ISBGT
RTS
BCCorBGTorBLEcode11 JSR ISBLE
RTS
***************************** END BCCorBGTorBLE ************************************
*----------- OR_BorOR_WorOR_LorDIVU ------------------------
OR_BorOR_WorOR_LorDIVU:
LEA tableOR_BorOR_WorOR_LorDIVU, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #7,D1 ; Shift 7 bits left
LSL.W D1,D0
MOVE.B #13,D1 ; Shift 13 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableOR_BorOR_WorOR_LorDIVU
JMP OR_DIVUcode000 ; OR.B
JMP OR_DIVUcode001 ; OR.W
JMP OR_DIVUcode010 ; OR.L
JMP OR_DIVUcode011 ; DIVU.W
JMP OR_DIVUcode100 ; OR.B
JMP OR_DIVUcode101 ; OR.W
JMP OR_DIVUcode110 ; OR.L
JMP OR_DIVUcode111 ; INVALID
OR_DIVUcode000 JSR ISORB
RTS
OR_DIVUcode001 JSR ISORW
RTS
OR_DIVUcode010 JSR ISORL
RTS
OR_DIVUcode011 JSR ISDIVUW
RTS
OR_DIVUcode100 JSR ISORB
RTS
OR_DIVUcode101 JSR ISORW
RTS
OR_DIVUcode110 JSR ISORL
RTS
OR_DIVUcode111 JSR OPCODE_INVALID ;INVALID
RTS
*----------- END ADD_BorADD_WorADD_L ----------------------
*----------- someASR ---------------------------------------
someASR:
LEA tableSomeASR, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #8,D1 ; Shift 8 bits left
LSL.W D1,D0
MOVE.B #14,D1 ; Shift 14 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableSomeASR:
JMP ASRcode00 *ASR.B
JMP ASRcode01 *ASR.W
JMP ASRcode10 *ASR.L
JMP ASRcode11 *ASR.W
ASRcode00 JSR ISASRB
RTS
ASRcode01 JSR ISASRW
RTS
ASRcode10 JSR ISASRL
RTS
ASRcode11 JSR ISASRW
RTS
*----------- END someLSL -----------------------------------
*----------- someASL ---------------------------------------
someASL:
LEA tableSomeASL, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #8,D1 ; Shift 8 bits left
LSL.W D1,D0
MOVE.B #14,D1 ; Shift 14 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableSomeASL:
JMP ASLcode00 *ASL.B
JMP ASLcode01 *ASL.W
JMP ASLcode10 *ASL.L
JMP ASLcode11 *ASL.W
ASLcode00 JSR ISASLB
RTS
ASLcode01 JSR ISASLW
RTS
ASLcode10 JSR ISASLL
RTS
ASLcode11 JSR ISASLW
RTS
*----------- END someLSL -----------------------------------
*----------- someLSR ---------------------------------------
someLSR:
LEA tableSomeLSR, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #8,D1 ; Shift 8 bits left
LSL.W D1,D0
MOVE.B #14,D1 ; Shift 14 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableSomeLSR:
JMP LSRcode00 *LSR.B
JMP LSRcode01 *LSR.W
JMP LSRcode10 *LSR.L
JMP LSRcode11 *LSR.W
LSRcode00 JSR ISLSRB
RTS
LSRcode01 JSR ISLSRW
RTS
LSRcode10 JSR ISLSRL
RTS
LSRcode11 JSR ISLSRW
RTS
*----------- END someLSR -----------------------------------
*----------- someLSL ---------------------------------------
someLSL:
LEA tableSomeLSL, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #8,D1 ; Shift 8 bits left
LSL.W D1,D0
MOVE.B #14,D1 ; Shift 14 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableSomeLSL:
JMP LSLcode00 *LSL.B
JMP LSLcode01 *LSL.W
JMP LSLcode10 *LSL.L
JMP LSLcode11 *LSL.W
LSLcode00 JSR ISLSLB
RTS
LSLcode01 JSR ISLSLW
RTS
LSLcode10 JSR ISLSLL
RTS
LSLcode11 JSR ISLSLW
RTS
*----------- END someLSL -----------------------------------
*----------- someROL ---------------------------------------
someROL:
LEA tableSomeROL, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #8,D1 ; Shift 8 bits left
LSL.W D1,D0
MOVE.B #14,D1 ; Shift 14 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableSomeROL:
JMP ROLcode00 *ROL.B
JMP ROLcode01 *ROL.W
JMP ROLcode10 *ROL.L
JMP ROLcode11 *ROL.W
ROLcode00 JSR ISROLB
RTS
ROLcode01 JSR ISROLW
RTS
ROLcode10 JSR ISROLL
RTS
ROLcode11 JSR ISROLW
RTS
*----------- END someROR -----------------------------------
*----------- someROR ---------------------------------------
someROR:
LEA tableSomeROR, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #8,D1 ; Shift 8 bits left
LSL.W D1,D0
MOVE.B #14,D1 ; Shift 14 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableSomeROR:
JMP RORcode00 *ROR.B
JMP RORcode01 *ROR.W
JMP RORcode10 *ROR.L
JMP RORcode11 *ROR.W
RORcode00 JSR ISRORB
RTS
RORcode01 JSR ISRORW
RTS
RORcode10 JSR ISRORL
RTS
RORcode11 JSR ISRORW
RTS
*----------- END someROR -----------------------------------
*----------- ROL_ROR ---------------------------------------
ROL_ROR:
LEA tableROL_ROR, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #7,D1 ; Shift 7 bits left
LSL.W D1,D0
MOVE.B #15,D1 ; Shift 15 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableROL_ROR:
JMP ROL_RORcode0 ; ROR
JMP ROL_RORcode1 ; ROL
ROL_RORcode0 JSR someROR
RTS
ROL_RORcode1 JSR someROL
RTS
*----------- END ROL_ROR -----------------------------------
*----------- LSL_LSR ---------------------------------------
LSL_LSR:
LEA tableLSL_LSR, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #7,D1 ; Shift 7 bits left
LSL.W D1,D0
MOVE.B #15,D1 ; Shift 15 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableLSL_LSR:
JMP LSL_LSRcode0 ; LSR
JMP LSL_LSRcode1 ; LSL
LSL_LSRcode0 JSR someLSR
RTS
LSL_LSRcode1 JSR someLSL
RTS
*----------- END LSL_LSR -----------------------------------
*----------- ASL_ASR ---------------------------------------
ASL_ASR:
LEA tableASL_ASR, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #7,D1 ; Shift 7 bits left
LSL.W D1,D0
MOVE.B #15,D1 ; Shift 15 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableASL_ASR:
JMP ASL_ASRcode0 ; ASR
JMP ASL_ASRcode1 ; ASL
ASL_ASRcode0 JSR someASR
RTS
ASL_ASRcode1 JSR someASL
RTS
*----------- END ASL_ASR -----------------------------------
*----------- ROd_LSd_ASd -----------------------------------
ROd_LSd_ASd:
LEA tableROd_LSd_ASd, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #11,D1 ; Shift 11 bits left
LSL.W D1,D0
MOVE.B #15,D1 ; Shift 12 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableROd_LSd_ASd:
JMP ROd_LSd_ASdcode00 ; ASL_ASR
JMP ROd_LSd_ASdcode01 ; LSL_LSR
JMP ROd_LSd_ASdcode10
JMP ROd_LSd_ASdcode11 ; ROL_ROR
ROd_LSd_ASdcode00 JSR ASL_ASR
RTS
ROd_LSd_ASdcode01 JSR LSL_LSR
RTS
ROd_LSd_ASdcode10 JSR OPCODE_INVALID ;INVALID
RTS
ROd_LSd_ASdcode11 JSR ROL_ROR
RTS
*----------- END ROd_LSd_ASd ------------------------------
*----------- AND_BorAND_WorAND_LorMULS_W -------------------
AND_BorAND_WorAND_LorMULS_W:
LEA tableAND_BorAND_WorAND_LorMULS_W, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #7,D1 ; Shift 7 bits left
LSL.W D1,D0
MOVE.B #13,D1 ; Shift 13 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableAND_BorAND_WorAND_LorMULS_W:
JMP ANDcode000 ; AND.B
JMP ANDcode001 ; AND.W
JMP ANDcode010 ; AND.L
JMP ANDcode011
JMP ANDcode100 ; AND.B
JMP ANDcode101 ; AND.W
JMP ANDcode110 ; AND.L
JMP ANDcode111 ; MULS.W
ANDcode000 JSR ISANDB
RTS
ANDcode001 JSR ISANDW
RTS
ANDcode010 JSR ISANDL
RTS
ANDcode011 JSR OPCODE_INVALID ;INVALID
RTS
ANDcode100 JSR ISANDB
RTS
ANDcode101 JSR ISANDW
RTS
ANDcode110 JSR ISANDL
RTS
ANDcode111 JSR ISMULSW
RTS
*----------- END ADD_BorADD_WorADD_L ----------------------
*----------- ADD_BorADD_WorADD_L ---------------------------
ADD_BorADD_WorADD_L:
LEA tableADD_BorADD_WorADD_L, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #7,D1 ; Shift 7 bits left
LSL.W D1,D0
MOVE.B #13,D1 ; Shift 13 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableADD_BorADD_WorADD_L:
JMP ADDcode000 *ADD.B
JMP ADDcode001 *ADD.W
JMP ADDcode010 *ADD.L
JMP ADDcode011 *ADDA.W
JMP ADDcode100 *ADD.B
JMP ADDcode101 *ADD.W
JMP ADDcode110 *ADD.L
JMP ADDcode111 *ADDA.L
ADDcode000 JSR ISADDB
RTS
ADDcode001 JSR ISADDW
RTS
ADDcode010 JSR ISADDL
RTS
ADDcode011 JSR ISADDAW
RTS
ADDcode100 JSR ISADDB
RTS
ADDcode101 JSR ISADDW
RTS
ADDcode110 JSR ISADDL
RTS
ADDcode111 JSR ISADDAL
RTS
*----------- END ADD_BorADD_WorADD_L ----------------------
*----------- SUB_BorSUB_WorSUB_L ---------------------------
SUB_BorSUB_WorSUB_L:
LEA tableSUB_BorSUB_WorSUB_L, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #7,D1 ; Shift 7 bits left
LSL.W D1,D0
MOVE.B #13,D1 ; Shift 13 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableSUB_BorSUB_WorSUB_L:
JMP SUBcode000 *SUB.B
JMP SUBcode001 *SUB.W
JMP SUBcode010 *SUB.L
JMP SUBcode011
JMP SUBcode100 *SUB.B
JMP SUBcode101 *SUB.W
JMP SUBcode110 *SUB.L
JMP SUBcode111 ; INVALID
SUBcode000 JSR ISSUBB
RTS
SUBcode001 JSR ISSUBW
RTS
SUBcode010 JSR ISSUBL
RTS
SUBcode011 JSR OPCODE_INVALID ;INVALID
RTS
SUBcode100 JSR ISSUBB
RTS
SUBcode101 JSR ISSUBW
RTS
SUBcode110 JSR ISSUBL
RTS
SUBcode111 JSR OPCODE_INVALID ;INVALID
RTS
*----------- END SUB_BorSUB_WorSUB_L ----------------------
*----------- CMP_BorCMP_WorCMP_L ---------------------------
CMP_BorCMP_WorCMP_L:
LEA tableCMP_BorCMP_WorCMP_L, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #8,D1 ; Shift 8 bits left
LSL.W D1,D0
MOVE.B #14,D1 ; Shift 14 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableCMP_BorCMP_WorCMP_L:
JMP CMPcode00 *CMP.B
JMP CMPcode01 *CMP.W
JMP CMPcode10 *CMP.L
JMP CMPcode11 ; INVALID
CMPcode00 JSR ISCMPB
RTS
CMPcode01 JSR ISCMPW
RTS
CMPcode10 JSR ISCMPL
RTS
CMPcode11 JSR OPCODE_INVALID ;INVALID
RTS
*----------- END CMP_BorCMP_WorCMP_L -----------------------
*----------- ADDQ_BorADDQ_WorADDQ_L ------------------------
ADDQ_BorADDQ_WorADDQ_L:
LEA tableADDQ_BorADDQ_WorADDQ_L, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #8,D1 ; Shift 8 bits left
LSL.W D1,D0
MOVE.B #14,D1 ; Shift 14 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableADDQ_BorADDQ_WorADDQ_L:
JMP ADDQcode00 *ADDQ.B
JMP ADDQcode01 *ADDQ.W
JMP ADDQcode10 *ADDQ.L
JMP ADDQcode11 ; INVALID
ADDQcode00 JSR ISADDQB
RTS
ADDQcode01 JSR ISADDQW
RTS
ADDQcode10 JSR ISADDQL
RTS
ADDQcode11 JSR OPCODE_INVALID ;INVALID
RTS
*----------- END ADDQ_BorADDQ_WorADDQ_L --------------------
*----------- someCLR ---------------------------------------
someCLR:
LEA tableSomeCLR, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #8,D1 ; Shift 8 bits left
LSL.W D1,D0
MOVE.B #14,D1 ; Shift 12 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableSomeCLR:
JMP CLRcode00 *CLR.B
JMP CLRcode01 *CLR.W
JMP CLRcode10 *CLR.L
JMP CLRcode11 ; INVALID
CLRcode00 JSR ISCLRB
RTS
CLRcode01 JSR ISCLRW
RTS
CLRcode10 JSR ISCLRL
RTS
CLRcode11 JSR OPCODE_INVALID ;INVALID
RTS
*----------- END someCLR -----------------------------------
*----------- NOPorCLRorRTSorJSR ----------------------------
NOPorCLRorRTSorJSR:
LEA tableNOPorCLRorRTSorJSR, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.W #%0100111001110001, D1 ; 0100111001110001 = NOP
CMP.W D0, D1
BEQ NOPcommand
MOVE.W #%0100111001110101, D1 ; 0100111001110101 = RTS
CMP.W D0, D1
BEQ RTScommand
MOVE.B #4,D1 ; Shift 4 bits left
LSL.W D1,D0
MOVE.B #12,D1 ; Shift 12 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableNOPorCLRorRTSorJSR:
JMP JSRorCLRcode0000
JMP JSRorCLRcode0001
JMP JSRorCLRcode0010
JMP JSRorCLRcode0011
JMP JSRorCLRcode0100
JMP JSRorCLRcode0101
JMP JSRorCLRcode0110
JMP JSRorCLRcode0111
JMP JSRorCLRcode1000
JMP JSRorCLRcode1001
JMP JSRorCLRcode1010
JMP JSRorCLRcode1011
JMP JSRorCLRcode1100
JMP JSRorCLRcode1101
JMP JSRorCLRcode1110
JMP JSRorCLRcode1111
RTScommand JSR ISRTS
RTS
NOPcommand JSR ISNOP
RTS
JSRorCLRcode0000 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode0001 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode0010 JSR someCLR
RTS
JSRorCLRcode0011 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode0100 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode0101 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode0110 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode0111 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode1000 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode1001 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode1010 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode1011 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode1100 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode1101 JSR OPCODE_INVALID ;INVALID
RTS
JSRorCLRcode1110 JSR ISJSR
RTS
JSRorCLRcode1111 JSR OPCODE_INVALID ;INVALID
RTS
*----------- END NOPorCLRorRTSorJSR ------------------------
*----------- someMOVEM -------------------------------------
someMOVEM:
LEA tableSomeMOVEM, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #9,D1 ; Shift 9 bits left
LSL.W D1,D0
MOVE.B #15,D1 ; Shift 12 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableSomeMOVEM:
JMP MOVEMcode0 ; MOVEM.W
JMP MOVEMcode1 ; MOVEM.L
MOVEMcode0 JSR ISMOVEMW
RTS
MOVEMcode1 JSR ISMOVEML
RTS
*----------- END someMOVEM ---------------------------------
*----------- NOP_MOVEM_LEA_JSR_CLR_RTS ---------------------
NOP_MOVEM_LEA_JSR_CLR_RTS:
LEA tableNOP_MOVEM_LEA_JSR_CLR_RTS, A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #7,D1 ; Shift 7 bits right
LSR.W D1,D0
MOVE.B #13,D1 ; Shift 13 bits left
LSL.W D1,D0
MOVE.B #12,D1 ; Shift 12 bits to the right
LSR.W D1,D0 ; Move the bits (moves highest 4 bits to lowest 4 positions,
; and the rest are zeroed out)
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableNOP_MOVEM_LEA_JSR_CLR_RTS:
JMP LOTScode0000
JMP LOTScode0001
JMP LOTScode0010
JMP LOTScode0011
JMP LOTScode0100
JMP LOTScode0101
JMP LOTScode0110
JMP LOTScode0111
JMP LOTScode1000
JMP LOTScode1001
JMP LOTScode1010
JMP LOTScode1011
JMP LOTScode1100
JMP LOTScode1101
JMP LOTScode1110
JMP LOTScode1111
LOTScode0000 JSR OPCODE_INVALID ; MULS.L and DIVU.L are not supported for 68000 Disassember
RTS
LOTScode0001 JSR OPCODE_INVALID ;INVALID
RTS
LOTScode0010 JSR someMOVEM
RTS
LOTScode0011 JSR OPCODE_INVALID ;INVALID
RTS
LOTScode0100 JSR OPCODE_INVALID ;INVALID
RTS
LOTScode0101 JSR OPCODE_INVALID ;INVALID
RTS
LOTScode0110 JSR ISLEA
RTS
LOTScode0111 JSR OPCODE_INVALID ;INVALID
RTS
LOTScode1000 JSR NOPorCLRorRTSorJSR
RTS
LOTScode1001 JSR OPCODE_INVALID ;INVALID
RTS
LOTScode1010 JSR NOPorCLRorRTSorJSR
RTS
LOTScode1011 JSR OPCODE_INVALID ;INVALID
RTS
LOTScode1100 JSR OPCODE_INVALID ;INVALID
RTS
LOTScode1101 JSR OPCODE_INVALID ;INVALID
RTS
LOTScode1110 JSR ISLEA
RTS
LOTScode1111 JSR OPCODE_INVALID ;INVALID
RTS
*----------- END NOP_MOVEM_LEA_JSR_CLR_RTS -----------------
*----------- ADDI_BorADDI_WorADDI_L ------------------------
ADDI_BorADDI_WorADDI_L:
LEA tableADDI_BorADDI_WorADDI_L,A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #7,D1 ; Shift 7 bits left
LSL.W D1,D0
MOVE.B #13,D1 ; Shift 13 bits right
LSR.W D1,D0
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableADDI_BorADDI_WorADDI_L:
JMP ADDIBcode00
JMP ADDIWcode01
JMP ADDILcode10
JMP ADDILcode11
ADDIBcode00 JSR ISADDIB
RTS
ADDIWcode01 JSR ISADDIW
RTS
ADDILcode10 JSR ISADDIL
RTS
ADDILcode11 JSR OPCODE_INVALID ;INVALID
RTS
*----------- END ADDI_BorADDI_WorADDI_L --------------------
*----------- MOVEA_LorMOVE_L -------------------------------
MOVEA_LorMOVE_L:
LEA tableMOVEA_LorMOVE_L,A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #7,D1 ; Shift 7 bits left
LSL.W D1,D0 ; 0011 1010 0100 0100 to 0010 0000 0000 0000
MOVE.B #13,D1 ; Shift 13 bits right
LSR.W D1,D0 ; 0010 0000 0000 0000 to 0000 0000 0000 0001
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableMOVEA_LorMOVE_L:
JMP MOVEcode000
JMP MOVEAcode001
JMP MOVEcode010
JMP MOVEcode011
JMP MOVEcode100
JMP MOVEcode101
JMP MOVEcode110
JMP MOVEcode111
MOVEcode000 JSR ISMOVEL
RTS
MOVEAcode001 JSR ISMOVEAL
RTS
MOVEcode010 JSR ISMOVEL
RTS
MOVEcode011 JSR ISMOVEL
RTS
MOVEcode100 JSR ISMOVEL
RTS
MOVEcode101 JSR ISMOVEL
RTS
MOVEcode110 JSR ISMOVEL
RTS
MOVEcode111 JSR ISMOVEL
RTS
*----------- END MOVEA_LorMOVE_L ---------------------------
*----------- MOVEA_WorMOVE_W -------------------------------
MOVEA_WorMOVE_W:
LEA tableMOVEA_WorMOVE_W,A0 ; Index into the table
CLR.L D0 ; Zero it
MOVE.W (A6),D0 ; We'll play with it here
MOVE.B #7,D1 ; Shift 7 bits left
LSL.W D1,D0 ; 0011 1010 0100 0100 to 0010 0000 0000 0000
MOVE.B #13,D1 ; Shift 13 bits right
LSR.W D1,D0 ; 0010 0000 0000 0000 to 0000 0000 0000 0001
MULU #6,D0 ; Form offset (move 6 bytes in memory for every 'JMP' command)
JMP 0(A0,D0) ; Jump indirect with index, i.e. jump to 'table' + displacement
tableMOVEA_WorMOVE_W:
JMP MOVEWcode000
JMP MOVEAWcode001
JMP MOVEWcode010
JMP MOVEWcode011
JMP MOVEWcode100
JMP MOVEWcode101
JMP MOVEWcode110
JMP MOVEWcode111
MOVEWcode000 JSR ISMOVEW
RTS
MOVEAWcode001 JSR ISMOVEAW
RTS
MOVEWcode010 JSR ISMOVEW
RTS
MOVEWcode011 JSR ISMOVEW
RTS
MOVEWcode100 JSR ISMOVEW
RTS
MOVEWcode101 JSR ISMOVEW
RTS
MOVEWcode110 JSR ISMOVEW
RTS
MOVEWcode111 JSR ISMOVEW
RTS
*----------- END MOVEA_WorMOVE_W ---------------------------
*----------- All 'IS' Subroutines --------------------------
; TODO: adjust workflow to:
; 1) save message address to buffer pointer
OPCODE_INVALID JSR INVALID_DATA
ADDA.L #$00000002, A6 ; Increment past current opcode word
RTS
ISBCC:
LEA MESSAGEBCC, A4
JSR WRITE2MEM
LEA TAB, A4
JSR WRITE2MEM
JSR EA_Bcc
RTS
ISBGT:
LEA MESSAGEBGT, A4
JSR WRITE2MEM
LEA TAB, A4
JSR WRITE2MEM
JSR EA_Bcc
RTS
ISBLE:
LEA MESSAGEBLE, A4
JSR WRITE2MEM
LEA TAB, A4
JSR WRITE2MEM
JSR EA_Bcc
RTS
ISDIVUW:
LEA MESSAGEDIVUW, A4
JSR WRITE2MEM
LEA TAB, A4
JSR WRITE2MEM
JSR EA_DIVU_W
RTS
ISORB:
LEA MESSAGEORB, A4
JSR WRITE2MEM
LEA TAB, A4
JSR WRITE2MEM
JSR EA_OR
RTS
ISORW:
LEA MESSAGEORW, A4
JSR WRITE2MEM
LEA TAB, A4
JSR WRITE2MEM
JSR EA_OR
RTS
ISORL:
LEA MESSAGEORL, A4
JSR WRITE2MEM
LEA TAB, A4
JSR WRITE2MEM
JSR EA_OR
RTS
ISASRB:
LEA MESSAGEASRB, A4
JSR WRITE2MEM
LEA TAB, A4
JSR WRITE2MEM
JSR EA_ASd
RTS
ISASRW:
LEA MESSAGEASRW, A4
JSR WRITE2MEM
LEA TAB, A4
JSR WRITE2MEM
JSR EA_ASd
RTS
ISASRL:
LEA MESSAGEASRL, A4
JSR WRITE2MEM
LEA TAB, A4
JSR WRITE2MEM
JSR EA_ASd
RTS
ISASLB:
LEA MESSAGEASLB, A4
JSR WRITE2MEM
LEA TAB, A4
JSR WRITE2MEM
JSR EA_ASd