-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHardwareBuddies_Win2014.X68
3923 lines (3232 loc) · 112 KB
/
HardwareBuddies_Win2014.X68
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 : easy68K Decompiler; Hardware Buddies
* Written by : Jeff Graham, David Lambert, Paul Pierot
* Date : 2/20/2014
* Description: A program to decompile machine code into assembly language
*-----------------------------------------------------------
CR EQU $0D
LF EQU $0A
DECOM_S EQU $1000 ;Defining the starting address of the Decompiler
START ORG $1000
*---Starts the Loop---
BEGIN LEA HEADER,A1 ;Displays the Header
MOVE.B #14,D0 ;+
TRAP #15 ;+
MOVE.B #0,D3 ;The loop counter starts at 0, goes to 29
*---Input---
LOOP MOVE.B #5,D0 ;Reads in Input
TRAP #15 ;+
CMP.B #89,D1 ;Branch to Decompiler code if Input = "Y" or "y"
BEQ RANGE ;+
CMP.B #121,D1 ;+
BEQ RANGE ;+
CMP.B #78,D1 ;Branch to Exit if Input = "N" or "n"
BEQ EXIT ;+
CMP.B #110,D1 ;+
BEQ EXIT ;+
BRA INVALID ;Input is invalid
*-----------------------------------------------------------
* Subroutine : RANGE
* Written by : Paul Pierot
* Last Modified : 3/11/2014
* Description : Gets the range of memory addresses to run
* on, and checks to make sure they are not
* inside the decompiler program
* Purpose : To avoid invalid input of memory addresses
* Inputs : N/A
* Outputs : A3 will contain the starting memory
* address as a word
* A4 will contain the ending memory
* address as a word
*-----------------------------------------------------------
RANGE LEA RANGE_S,A1 ;Requests the starting address
MOVE.B #14,D0 ;+
TRAP #15 ;+
BSR GETHEX ;Gets the user's input and converts it into a hexadecimal address
CMP.W #DECOM_E,D5 ;If the Address is less than the ending address of the decompiler, throw an error
BLE INVALID ;+
MOVEA.W D5,A3 ;Moves the starting address into A3
LEA RANGE_E,A1 ;Requests the ending address
MOVE.B #14,D0 ;+
TRAP #15 ;+
BSR GETHEX ;Gets the user's input and converts it into a hexadecimal address
CMP.W #DECOM_E,D5 ;If the Address is less than the ending address of the decompiler, throw an error
BLE INVALID ;+
MOVEA.W D5,A4 ;Moves the ending address into A4
MOVE.L #0,D5 ;Cleans out D5 & D4
MOVE.L #0,D4 ;+
MOVE.W A3,D5 ;Move the starting address into D5
MOVE.W A4,D4 ;Move the ending address into D4
CMP.W D4,D5 ;If the ending address is less than the starting address, throw an error
BGT INVALID ;+
LEA VALID,A1 ;Let the user know their input was valid
MOVE.B #14,D0 ;+
TRAP #15 ;+
BSR CLEAR ;Clear the screen
BRA decodeOp ;Start decompiling
*-----------------------------------------------------------
* Subroutine : GETHEX
* Written by : Paul Pierot
* Last Modified : 3/8/2014
* Description : Reads in the users input as a hexadecimal.
* Can only read in 4 hexadecimals
* Purpose : To convert the users input into hexadecimal
* Inputs : N/A
* Outputs : D5 will contain the hexadecimal input
*-----------------------------------------------------------
GETHEX LEA INPUT,A1 ;Loads the INPUT variable into A1
CLR D2 ;D2 holds the number of hexadecimals read
READHEX MOVE #5,D0 ;Start a loop to read single characters
TRAP #15 ;+
CMP.B #13,D1 ;If the user presses Enter, exit the loop
BEQ HEXFIN ;Jump to convertion into Hexadecimal
BRA HEX_BIN ;Convert the character into binary
BRA READHEX ;Starts the next loop
HEX_BIN CMP.B #71,D1 ;If the character is G or higher, throw an error
BGE INVAL_C ;+
CMP.B #47,D1 ;If the character is / or lower, throw an error
BLE INVAL_C ;+
CMP.B #57,D1 ;Determines if the character is 0~9 or A~F
BLE ISNUMB ;+
SUB.B #55,D1 ;Character is A~F, and A is decimal 65, so subtract 55 to get the decimal value
CMP.B #64,D1 ;If the character is not a letter, throw an error
BGE INVAL_C ;+
BRA STORE ;Jumps to storing the character
ISNUMB SUB.B #48,D1 ;Character is 0~9, and 0 is decimal 48, so subtract 48 to get the decimal value
STORE MOVE.B D1,(A1)+ ;Stores the converted value into INPUT
ADD #1,D2 ;Increments to count the number of characters
BRA READHEX ;Jump back to the READHEX loop
HEXFIN CMP #0,D2 ;If no characters have been entered, throw an error
BEQ INVALID ;+
CLR D5 ;D5 holds the final value
MOVE.L #16,D4 ;D4 is used to multiply by a power of 16
MOVE.B -(A1),D5 ;Get the least significant byte
GETNEXT SUB.B #1,D2 ;Decrement the counter in D2 as we read in the next value
TST.B D2 ;If there's no more values to read, finish the subroutine
BEQ HEXDONE ;+
MOVE.B -(A1),D6 ;Gets the next hexadecimal
MULU D4,D6 ;Multiplies the hexadecimal by a power of 16 to get the position
ADD.L D6,D5 ;Adds the hexadecimal to the total
MULU #16,D4 ;Increase the power
BRA GETNEXT ;Loop back to GETNEXT
HEXDONE MOVE.L #0,D4 ;Clean out D4 & D6
MOVE.L #0,D6 ;+
RTS ;Return to the routine that called GETHEX
*-----------------------------------------------------------
* Subroutine : INVALID
* Written by : Paul Pierot
* Last Modified : 3/11/2014
* Description : Displays a generic warning to the user
* Purpose : To alert the user of invalid input
* Inputs : N/A
* Outputs : N/A
*-----------------------------------------------------------
INVALID LEA INV_I,A1 ;Displays a warning message
MOVE.B #14,D0 ;+
TRAP #15 ;+
BSR CLEAR ;Clear the screen
BSR EMPTY ;Clean out the registers
BRA BEGIN ;Branches back to the Header
*-----------------------------------------------------------
* Subroutine : INVAL_C
* Written by : Paul Pierot
* Last Modified : 3/11/2014
* Description : Displays a warning to the user
* Purpose : To alert the user of an invalid character
* Inputs : N/A
* Outputs : N/A
*-----------------------------------------------------------
INVAL_C LEA INV_C,A1 ;Displays a warning message
MOVE.B #14,D0 ;+
TRAP #15 ;+
BSR CLEAR ;Clear the screen
BSR EMPTY ;Clean out the registers
BRA BEGIN ;Branches back to the Header
*-----------------------------------------------------------
* Subroutine : CLEAR
* Written by : Paul Pierot
* Last Modified : 2/12/2014
* Description : Clears the screen and jumps back to the
* beginning of the program
* Purpose : To easily allow the program to restart
* Inputs : N/A
* Outputs : N/A
*-----------------------------------------------------------
CLEAR LEA CONT,A1 ;Display a continue message
MOVE.B #14,D0 ;+
TRAP #15 ;+
MOVE.B #4,D0 ;Reads in an input, not used
TRAP #15 ;+
MOVE.B #11,D0 ;Clears the screen
MOVE.W #$FF00,D1 ;+
TRAP #15 ;+
RTS
*-----------------------------------------------------------
* Subroutine : decodeOp
* Written by : Jeff Graham, Paul Pierot
* Last Modified : 3/11/14
* Description : sorts opcodes according to groups based on their first 4-bits
* Purpose : The first step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
decodeOp
*Initialize variables
LEA opBuffer,A2 *set op buffer ptr
CLR.L D2 *clear old opcode
MOVE.W (A3),D2 *store opcode in D2 for processing
MOVE.W A3,D1 ;Convert the memory address into ASCII text
MOVE.B #4,D4 ;+
BSR hexToASCII ;+
LEA OUTPUT,A1 ;Print the memory address to the screen
MOVE.B #14,D0 ;+
TRAP #15 ;+
LEA COLON,A1 ;Print ": " for readability
TRAP #15 ;+
ADDA.L #2,A3 *advance ptr
*get first four bit value
MOVE.B #3,D6 *specify most significant four bits wanted
BSR fourBitValue *store first four bits in D7
*compare value, and branch to group SR
CMPI.B #0,D7
BEQ grpZero
CMPI.B #1,D7
BEQ grpOne
CMPI.B #2,D7
BEQ grpTwo
CMPI.B #3,D7
BEQ grpThree
CMPI.B #4,D7
BEQ grpFour
CMPI.B #5,D7
BEQ grpFive
CMPI.B #6,D7
BEQ grpSix
CMPI.B #7,D7
BEQ grpSeven
CMPI.B #8,D7
BEQ grpEight
CMPI.B #9,D7
BEQ grpNine
CMPI.B #10,D7
BEQ grpTen
CMPI.B #11,D7
BEQ grpEleven
CMPI.B #12,D7
BEQ grpTwelve
CMPI.B #13,D7
BEQ grpThirteen
CMPI.B #14,D7
BEQ grpFourteen
CMPI.B #15,D7
BEQ grpFifteen
*every op is covered, no need for unknownOp branch
*First level group sorting
*-----------------------------------------------------------
* Subroutine : grpZero
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : sorts group zero opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpZero
MOVE.B #2,D6 *select which 4-bit set to evaluate
BSR fourBitValue
*compare 4-bit data to determine opcode
CMPI.B #2,D7
BEQ opANDI
CMPI.B #6,D7
BEQ opADDI
CMPI.B #8,D7
BEQ opBCHGStat
CMPI.B #10,D7
BEQ opEORI
CMPI.B #12,D7
BEQ opCMPI
*check if odd value
ANDI.B #1,D7
CMPI.B #1,D7
BEQ opBCHGDyn
*check for unknown code
BRA unknownOp
*-----------------------------------------------------------
* Subroutine : grpOne
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : sorts group one opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpOne
BRA opMOVEB
*-----------------------------------------------------------
* Subroutine : grpTwo
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : sorts group two opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpTwo
BRA opMOVEL
*-----------------------------------------------------------
* Subroutine : grpThree
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : sorts group three opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpThree
BRA opMOVEW
*-----------------------------------------------------------
* Subroutine : grpFour
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : sorts group four opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpFour
MOVE.B #2,D6 *select which 4-bit set to evaluate
BSR fourBitValue
*compare 4-bit data to determine opcode
CMPI.B #2,D7
BEQ opCLR
CMPI.B #8,D7
BEQ opMOVEMRtoM
CMPI.B #12,D7
BEQ chkMOVEMMtoRMULSL
CMPI.B #14,D7
BEQ chkJSRRTS
*check if odd
ANDI.B #1,D7
CMPI.B #1,D7
BEQ opLEA
*fall through to unknown
BRA unknownOp
*-----------------------------------------------------------
* Subroutine : chkMOVEMMtoRMULSL
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : Determines if the opcode is MOVEM in memory-to-Register mode
* or MULS.L
* Purpose : checks ambiguous opcodes next bits to determine which code
* it is.
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
chkMOVEMMtoRMULSL
MOVE.B #1,D6 *select which 4-bit set to evaluate
BSR fourBitValue
*if >= 8 -> MOVEMMtoR, else -> MULS.L
CMPI.B #8,D7
BGE opMOVEMMtoR *8 <= D7 -> opMOVEMMtoR
BRA opMULSL
*-----------------------------------------------------------
* Subroutine : chkJSRRTS
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : Determines if the opcode is JSR or RTS
* Purpose : checks ambiguous opcodes next bits to determine which code
* it is.
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
chkJSRRTS
MOVE.B #1,D6 *select which 4-bit set to evaluate
BSR fourBitValue
*if >= 8 -> JSR, else -> RTS
CMPI.B #8,D7
BGE opJSR *8 <= D7 -> opJSR
BRA opRTS *8 > D7 -> opRTS
*-----------------------------------------------------------
* Subroutine : grpFive
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : sorts group five opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpFive
BRA opSUBQ
*-----------------------------------------------------------
* Subroutine : grpSix
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : sorts group six opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpSix
MOVE.B #2,D6 *select which 4-bit set to evaluate
BSR fourBitValue
*compare 4-bit data to determine opcode
CMPI.B #4,D7
BEQ opBCC
CMPI.B #9,D7
BEQ opBVS
CMPI.B #14,D7
BEQ opBGT
CMPI.B #15,D7
BEQ opBLE
*fall through to unknown
BRA unknownOp
*-----------------------------------------------------------
* Subroutine : grpSeven
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : sorts group seven opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpSeven
BRA opMOVEQ
*-----------------------------------------------------------
* Subroutine : grpEight
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : sorts group eight opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpEight
BRA opDIVUW
*-----------------------------------------------------------
* Subroutine : grpNine
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : sorts group nine opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpNine
MOVE.B #1,D6 *Note: for this, we must check the third 4bit set
BSR fourBitValue
*compare 4-bit data to determine opcode
*if >= 12 -> SUBA, else -> SUB
CMPI.B #12,D7
BGE opSUBA
BRA opSUB
*-----------------------------------------------------------
* Subroutine : grpTen
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : sorts group ten opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpTen
BRA unknownOp
*-----------------------------------------------------------
* Subroutine : grpEleven
* Written by : Jeff Graham
* Last Modified : 3/11/14
* Description : sorts group eleven opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpEleven
*get opmode 3 bit field
BFEXTU D2{#23:#3},D7
*compare opmode field to determine opcode
*If 3, or 7 CMPA
CMPI.B #7,D7
BEQ opCMPA
CMPI.B #3,D7
BEQ opCMPA
*if 4,5, or 6 -> EOR
BGT opEOR
*if 0,1,2 -> CMP
BLT opCMP
*-----------------------------------------------------------
* Subroutine : grpTwelve
* Written by : Jeff Graham
* Last Modified : 3/11/14
* Description : sorts group twelve opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpTwelve
*get opmode 3 bit field
BFEXTU D2{#23:#3},D7
*compare opmode field to determine opcode
*If 7 CMPA
CMPI.B #7,D7
BEQ opMULSW
*if 3, unknown
CMPI.B #3,D7
BEQ unknownOp
*else AND
BRA opAND
*-----------------------------------------------------------
* Subroutine : grpThirteen
* Written by : Jeff Graham
* Last Modified : 3/11/14
* Description : sorts group thirteen opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpThirteen
*get 2 bit field
BFEXTU D2{#24:#2},D7
*compare opmode field to determine opcode
*if 3, ADDA
CMPI.B #3,D7
BEQ opADDA
*else ADD
BRA opADD
*-----------------------------------------------------------
* Subroutine : grpFourteen
* Written by : Jeff Graham
* Last Modified : 3/11/14
* Description : sorts group fourteen opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpFourteen
*check b6 & b7
BFEXTU D2{#24:#2},D7
*if == 3, then this will be a mem shift/rotate
CMPI.B #3,D7
BEQ grpFourteenMem
BRA grpFourteenReg
grpFourteenMem
*b11 must be 0, or unknown OP
BTST #11,D2
BNE unknownOp
*Check b9 & b10
MOVE.B #21,D5
BRA grpFourteenEnd
grpFourteenReg
*check b3 & b4
MOVE.B #27,D5
BRA grpFourteenEnd
grpFourteenEnd
*else this will be a register shift/rotate
BFEXTU D2{D5:#2},D7
*check unknown
CMPI.B #2,D7
BEQ unknownOp *if == 2 -> unknownOp
*check opcode
CMPI.B #1,D7
BLT opASd *if == 0 -> ASd
BEQ opLSd *if == 1 -> LSd
BGT opROd *if == 3 -> ROd
*-----------------------------------------------------------
* Subroutine : grpFifteen
* Written by : Jeff Graham
* Last Modified : 2/14/14
* Description : sorts group fifteen opcodes according to their second 4-bits
* Purpose : The second step in decoding an opcode
* Inputs : None (depends on the opcode pointer being A3)
* Outputs : None (branches to next SR in line)
*-----------------------------------------------------------
grpFifteen
BRA unknownOp
*
*opcode section, the following currently only print the opcodes and start
* decoding the next word.
*
*grp zero opcodes
*-----------------------------------------------------------
* Subroutine : opADDI
* Written by : Jeff Graham
* Last Modified : 3/11/14
* Description : Decodes the ADDI opcode
* Purpose : The final step in decoding opcode
*-----------------------------------------------------------
opADDI
*buffer opcode
LEA strADDI,A6
BSR toOutputBuffer
*check size
BFEXTU D2{#24:#2},D4 *get size bits
CMPI.B #0,D4
BEQ opADDIB
CMPI.B #1,D4
BEQ opADDIW
CMPI.B #2,D4
BEQ opADDIL
BRA unknownOp *size 3 is invalid
opADDIB
*buffer .B
LEA strByte,A6
BSR toOutputBuffer
*buffer 5x spaces
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
*move # to output Buffer
MOVE.B #35,(A2)+ *35 is ascii for #
*move $ to output buffer
MOVE.B #36,(A2)+ *36 is ascii code for $
*get ascii byte
ADDA.L #1,A3 *advance pointer one byte
MOVE.B (A3),D1 *move byte to be
MOVE.L #2,D4 *number of hex digits to convert
BSR hexToAscii *move byte to output buffer
*move ascii hex digits to output buffer
LEA OUTPUT,A6
BSR toOutputBuffer
ADDA.L #1,A3 *advance pointer one more byte
BRA opADDIEnd
opADDIW
*buffer .W
LEA strWord,A6
BSR toOutputBuffer
*buffer 5x spaces
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
*move # to output Buffer
MOVE.B #35,(A2)+ *35 is ascii for #
*move $ to output buffer
MOVE.B #36,(A2)+ *36 is ascii code for $
*get ascii word
MOVE.W (A3),D1
MOVE.L #4,D4 *# of hex digits to convert
BSR hexToAscii *move word to output buffer
*move ascii to output buffer
LEA OUTPUT,A6
BSR toOutputBuffer
ADDA.L #2,A3 *advance pointer one word
BRA opADDIEnd
opADDIL
*buffer .L
LEA strLong,A6
BSR toOutputBuffer
*buffer 5x spaces
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
*move # to output Buffer
MOVE.B #35,(A2)+ *35 is ascii for #
*move $ to output buffer
MOVE.B #36,(A2)+ *36 is ascii code for $
*get ascii longword
MOVE.L (A3),D1
MOVE.L #8,D4 *# of hex digits to convert
BSR hexToAscii *move long to output buffer
*move ascii to output buffer
LEA OUTPUT,A6
BSR toOutputBuffer
ADDA.L #4,A3 *advance pointer one longword
BRA opADDIEnd
opADDIEnd
*buffer ,
MOVE.B #44,(A2)+ *#44 is ascii val for comma
*get destination EA
*set invalid EA mask
BSET #30,D2
BSET #24,D2
*move register and mode
MOVE.B #0,D5 *store register
MOVE.B #3,D6 *store mode
BSR eaDecode
BSR printBuffer
BRA nextOp
*-----------------------------------------------------------
* Subroutine : opANDI
* Written by : Jeff Graham
* Last Modified : 3/11/14
* Description : Decodes the ANDI opcode
* Purpose : The final step in decoding opcode
*-----------------------------------------------------------
opANDI
*buffer opcode
LEA strANDI,A6
BSR toOutputBuffer
*check size
BFEXTU D2{#24:#2},D4 *get size bits
CMPI.B #0,D4
BEQ opANDIB
CMPI.B #1,D4
BEQ opANDIW
CMPI.B #2,D4
BEQ opANDIL
BRA unknownOp *size 3 is invalid
opANDIB
*buffer .B
LEA strByte,A6
BSR toOutputBuffer
*buffer 5x spaces
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
*move # to output Buffer
MOVE.B #35,(A2)+ *35 is ascii for #
*move $ to output buffer
MOVE.B #36,(A2)+ *36 is ascii code for $
*get ascii byte
ADDA.L #1,A3 *advance pointer one byte
MOVE.B (A3),D1 *move byte to be
MOVE.L #2,D4 *number of hex digits to convert
BSR hexToAscii *move byte to output buffer
*move ascii hex digits to output buffer
LEA OUTPUT,A6
BSR toOutputBuffer
ADDA.L #1,A3 *advance pointer one more byte
BRA opANDIEnd
opANDIW
*buffer .W
LEA strWord,A6
BSR toOutputBuffer
*buffer 5x spaces
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
*move # to output Buffer
MOVE.B #35,(A2)+ *35 is ascii for #
*move $ to output buffer
MOVE.B #36,(A2)+ *36 is ascii code for $
*get ascii word
MOVE.W (A3),D1
MOVE.L #4,D4 *# of hex digits to convert
BSR hexToAscii *move word to output buffer
*move ascii to output buffer
LEA OUTPUT,A6
BSR toOutputBuffer
ADDA.L #2,A3 *advance pointer one word
BRA opANDIEnd
opANDIL
*buffer .L
LEA strLong,A6
BSR toOutputBuffer
*buffer 5x spaces
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
*move # to output Buffer
MOVE.B #35,(A2)+ *35 is ascii for #
*move $ to output buffer
MOVE.B #36,(A2)+ *36 is ascii code for $
*get ascii longword
MOVE.L (A3),D1
MOVE.L #8,D4 *# of hex digits to convert
BSR hexToAscii *move long to output buffer
*move ascii to output buffer
LEA OUTPUT,A6
BSR toOutputBuffer
ADDA.L #4,A3 *advance pointer one longword
BRA opANDIEnd
opANDIEnd
*buffer ,
MOVE.B #44,(A2)+ *#44 is ascii val for comma
*get destination EA
*set invalid EA mask
BSET #30,D2
BSET #24,D2
*move register and mode
MOVE.B #0,D5 *store register
MOVE.B #3,D6 *store mode
BSR eaDecode
BSR printBuffer
BRA nextOp
*-----------------------------------------------------------
* Subroutine : opEORI
* Written by : Jeff Graham
* Last Modified : 3/11/14
* Description : Decodes the EORI opcode
* Purpose : The final step in decoding opcode
*-----------------------------------------------------------
opEORI
*Print opcode
LEA strEORI,A6
BSR toOutputBuffer
*check size
BFEXTU D2{#24:#2},D4 *get size bits
CMPI.B #0,D4
BEQ opEORIB
CMPI.B #1,D4
BEQ opEORIW
CMPI.B #2,D4
BEQ opEORIL
BRA unknownOp *size 3 is invalid
opEORIB
*buffer .B
LEA strByte,A6
BSR toOutputBuffer
*buffer 5x spaces
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
*move # to output Buffer
MOVE.B #35,(A2)+ *35 is ascii for #
*move $ to output buffer
MOVE.B #36,(A2)+ *36 is ascii code for $
*get ascii byte
ADDA.L #1,A3 *advance pointer one byte
MOVE.B (A3),D1 *move byte to be
MOVE.L #2,D4 *number of hex digits to convert
BSR hexToAscii *move byte to output buffer
*move ascii hex digits to output buffer
LEA OUTPUT,A6
BSR toOutputBuffer
ADDA.L #1,A3 *advance pointer one more byte
BRA opEORIEnd
opEORIW
*buffer .W
LEA strWord,A6
BSR toOutputBuffer
*buffer 5x spaces
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
*move # to output Buffer
MOVE.B #35,(A2)+ *35 is ascii for #
*move $ to output buffer
MOVE.B #36,(A2)+ *36 is ascii code for $
*get ascii word
MOVE.W (A3),D1
MOVE.L #4,D4 *# of hex digits to convert
BSR hexToAscii *move word to output buffer
*move ascii to output buffer
LEA OUTPUT,A6
BSR toOutputBuffer
ADDA.L #2,A3 *advance pointer one word
BRA opEORIEnd
opEORIL
*buffer .L
LEA strLong,A6
BSR toOutputBuffer
*buffer 5x spaces
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
MOVE.B #32,(A2)+
*move # to output Buffer
MOVE.B #35,(A2)+ *35 is ascii for #
*move $ to output buffer
MOVE.B #36,(A2)+ *36 is ascii code for $
*get ascii longword
MOVE.L (A3),D1
MOVE.L #8,D4 *# of hex digits to convert
BSR hexToAscii *move long to output buffer
*move ascii to output buffer
LEA OUTPUT,A6
BSR toOutputBuffer
ADDA.L #4,A3 *advance pointer one longword
BRA opEORIEnd
opEORIEnd
*buffer ,
MOVE.B #44,(A2)+ *#44 is ascii val for comma
*get destination EA
*set invalid EA mask
BSET #30,D2
BSET #24,D2
*move register and mode
MOVE.B #0,D5 *store register
MOVE.B #3,D6 *store mode
BSR eaDecode
BSR printBuffer