-
Notifications
You must be signed in to change notification settings - Fork 8
/
turbo9_urtl.asm
1645 lines (1215 loc) · 49.7 KB
/
turbo9_urtl.asm
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
; [TURBO9_HEADER_START]
; ////////////////////////////////////////////////////////////////////////////
; Turbo9 Microprocessor IP
; ////////////////////////////////////////////////////////////////////////////
; Website: www.turbo9.org
; Contact: team[at]turbo9[dot]org
; ////////////////////////////////////////////////////////////////////////////
; [TURBO9_LICENSE_START]
; BSD-1-Clause
;
; Copyright (c) 2020-2023
; Kevin Phillipson
; Michael Rywalt
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
;
; 1. Redistributions of source code must retain the above copyright notice,
; this list of conditions and the following disclaimer.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
; POSSIBILITY OF SUCH DAMAGE.
; [TURBO9_LICENSE_END]
; ////////////////////////////////////////////////////////////////////////////
; Engineer: Kevin Phillipson
; Description: Turbo9 uRTL microcode
;
; vim syntax :set syn=asm68k
;
; ////////////////////////////////////////////////////////////////////////////
; History:
; 07.14.2023 - Kevin Phillipson
; File header added
;
; ////////////////////////////////////////////////////////////////////////////
; [TURBO9_HEADER_END]
; decode_init <tablename> <ctrl_vec> <default_string> <input width> ; Comment
; Jump Table A
decode_init pg1_JTA cv_MICRO_SEQ_BRANCH_ADDR FF 8 ; Page 1
decode_init pg2_JTA cv_MICRO_SEQ_BRANCH_ADDR FF 8 ; Page 2
decode_init pg3_JTA cv_MICRO_SEQ_BRANCH_ADDR FF 8 ; Page 3
; Jump Table B
decode_init pg1_JTB cv_MICRO_SEQ_BRANCH_ADDR FF 8 ; Page 1
decode_init pg2_JTB cv_MICRO_SEQ_BRANCH_ADDR FF 8 ; Page 2
decode_init pg3_JTB cv_MICRO_SEQ_BRANCH_ADDR FF 8 ; Page 3
; Register A Decode
; A side of ALU and ALU write
decode_init pg1_R1 cv_R1_SEL x 8 ; Page 1
decode_init pg2_R1 cv_R1_SEL x 8 ; Page 2
decode_init pg3_R1 cv_R1_SEL x 8 ; Page 3
; Register B Decode
; B side of ALU
decode_init pg1_R2 cv_R2_SEL x 8 ; Page 1
decode_init pg2_R2 cv_R2_SEL x 8 ; Page 2
decode_init pg3_R2 cv_R2_SEL x 8 ; Page 3
; Address Register Decode
decode_init pg1_AR cv_AR_SEL x 8 ; Page 1
decode_init pg2_AR cv_AR_SEL x 8 ; Page 2
decode_init pg3_AR cv_AR_SEL x 8 ; Page 3
; decode <tablename> <equ> <opcode0...opcodeN> ; Comment
;
; EXAMPLE:
; decode pg1_JTA ABX $3A ; ABX(inh)
ORG $00
RESET:
; R1 is reset to PC
; R2 is reset to DMEM_RD
SET_DATA_WIDTH W_16
STACK_PUSH ZERO ; a cute way of creating EA=$FFFE
DMEM_LOAD_W
JUMP JMP
micro_op_end
; ////////////////////////////////////////////////////////////////////////////
; LOAD ADDRESSING MODES
; ////////////////////////////////////////////////////////////////////////////
; //
LD_DIR_EXT:
decode pg1_JTA LD_DIR_EXT $99 $B9 ; ADCA (dir ext)
decode pg1_JTA LD_DIR_EXT $D9 $F9 ; ADCB (dir ext)
;
decode pg1_JTA LD_DIR_EXT $9B $BB ; ADDA (dir ext)
decode pg1_JTA LD_DIR_EXT $DB $FB ; ADDB (dir ext)
decode pg1_JTA LD_DIR_EXT $D3 $F3 ; ADDD (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $94 $B4 ; ANDA (dir ext)
decode pg1_JTA LD_DIR_EXT $D4 $F4 ; ANDB (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $08 $78 ; ASL LSL (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $07 $77 ; ASR (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $95 $B5 ; BITA (dir ext)
decode pg1_JTA LD_DIR_EXT $D5 $F5 ; BITB (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $91 $B1 ; CMPA (dir ext)
decode pg1_JTA LD_DIR_EXT $D1 $F1 ; CMPB (dir ext)
decode pg2_JTA LD_DIR_EXT $93 $B3 ; CMPD (dir ext)
decode pg3_JTA LD_DIR_EXT $9C $BC ; CMPS (dir ext)
decode pg3_JTA LD_DIR_EXT $93 $B3 ; CMPU (dir ext)
decode pg1_JTA LD_DIR_EXT $9C $BC ; CMPX (dir ext)
decode pg2_JTA LD_DIR_EXT $9C $BC ; CMPY (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $03 $73 ; COM (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $0A $7A ; DEC (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $98 $B8 ; EORA (dir ext)
decode pg1_JTA LD_DIR_EXT $D8 $F8 ; EORB (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $0C $7C ; INC (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $96 $B6 ; LDA (dir ext)
decode pg1_JTA LD_DIR_EXT $D6 $F6 ; LDB (dir ext)
decode pg1_JTA LD_DIR_EXT $DC $FC ; LDD (dir ext)
decode pg2_JTA LD_DIR_EXT $DE $FE ; LDS (dir ext)
decode pg1_JTA LD_DIR_EXT $DE $FE ; LDU (dir ext)
decode pg1_JTA LD_DIR_EXT $9E $BE ; LDX (dir ext)
decode pg2_JTA LD_DIR_EXT $9E $BE ; LDY (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $04 $74 ; LSR (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $00 $70 ; NEG (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $9A $BA ; ORA (dir ext)
decode pg1_JTA LD_DIR_EXT $DA $FA ; ORB (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $09 $79 ; ROL (dir ext)
decode pg1_JTA LD_DIR_EXT $06 $76 ; ROR (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $92 $B2 ; SBCA (dir ext)
decode pg1_JTA LD_DIR_EXT $D2 $F2 ; SBCB (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $90 $B0 ; SUBA (dir ext)
decode pg1_JTA LD_DIR_EXT $D0 $F0 ; SUBB (dir ext)
decode pg1_JTA LD_DIR_EXT $93 $B3 ; SUBD (dir ext)
; //
decode pg1_JTA LD_DIR_EXT $0D $7D ; TST (dir ext)
DATA_PASS_B IDATA
DATA_WRITE EA
SET_DATA_WIDTH W_R1
ADDR_PASS IDATA
DMEM_LOAD_W
JUMP_TABLE_B
micro_op_end
LD_INDEXED:
decode pg1_JTA LD_INDEXED $A9 ; ADCA (idx)
decode pg1_JTA LD_INDEXED $E9 ; ADCB (idx)
; //
decode pg1_JTA LD_INDEXED $AB ; ADDA (idx)
decode pg1_JTA LD_INDEXED $EB ; ADDB (idx)
decode pg1_JTA LD_INDEXED $E3 ; ADDD (idx)
; //
decode pg1_JTA LD_INDEXED $A4 ; ANDA (idx)
decode pg1_JTA LD_INDEXED $E4 ; ANDB (idx)
; //
decode pg1_JTA LD_INDEXED $68 ; ASL LSL (idx)
; //
decode pg1_JTA LD_INDEXED $67 ; ASR (idx)
; //
decode pg1_JTA LD_INDEXED $A5 ; BITA (idx)
decode pg1_JTA LD_INDEXED $E5 ; BITB (idx)
; //
decode pg1_JTA LD_INDEXED $A1 ; CMPA (idx)
decode pg1_JTA LD_INDEXED $E1 ; CMPB (idx)
decode pg2_JTA LD_INDEXED $A3 ; CMPD (idx)
decode pg3_JTA LD_INDEXED $AC ; CMPS (idx)
decode pg3_JTA LD_INDEXED $A3 ; CMPU (idx)
decode pg1_JTA LD_INDEXED $AC ; CMPX (idx)
decode pg2_JTA LD_INDEXED $AC ; CMPY (idx)
; //
decode pg1_JTA LD_INDEXED $63 ; COM (idx)
; //
decode pg1_JTA LD_INDEXED $6A ; DEC (idx)
; //
decode pg1_JTA LD_INDEXED $A8 ; EORA (idx)
decode pg1_JTA LD_INDEXED $E8 ; EORB (idx)
; //
decode pg1_JTA LD_INDEXED $6C ; INC (idx)
; //
decode pg1_JTA LD_INDEXED $A6 ; LDA (idx)
decode pg1_JTA LD_INDEXED $E6 ; LDB (idx)
decode pg1_JTA LD_INDEXED $EC ; LDD (idx)
decode pg2_JTA LD_INDEXED $EE ; LDS (idx)
decode pg1_JTA LD_INDEXED $EE ; LDU (idx)
decode pg1_JTA LD_INDEXED $AE ; LDX (idx)
decode pg2_JTA LD_INDEXED $AE ; LDY (idx)
; //
decode pg1_JTA LD_INDEXED $64 ; LSR (idx)
; //
decode pg1_JTA LD_INDEXED $60 ; NEG (idx)
; //
decode pg1_JTA LD_INDEXED $AA ; ORA (idx)
decode pg1_JTA LD_INDEXED $EA ; ORB (idx)
; //
decode pg1_JTA LD_INDEXED $69 ; ROL (idx)
decode pg1_JTA LD_INDEXED $66 ; ROR (idx)
; //
decode pg1_JTA LD_INDEXED $A2 ; SBCA (idx)
decode pg1_JTA LD_INDEXED $E2 ; SBCB (idx)
; //
decode pg1_JTA LD_INDEXED $A0 ; SUBA (idx)
decode pg1_JTA LD_INDEXED $E0 ; SUBB (idx)
decode pg1_JTA LD_INDEXED $A3 ; SUBD (idx)
; //
decode pg1_JTA LD_INDEXED $6D ; TST (idx)
SET_DATA_WIDTH W_R1_OR_IND
ADDR_INX_OR_LOAD_IND
DMEM_LOAD_W ; LOAD_IND can override
IF NOT_INDIRECT
JUMP_TABLE_B
micro_op_end
LD_INDIRECT:
DATA_PASS_B DMEM_RD
DATA_WRITE EA
SET_DATA_WIDTH W_R1
ADDR_PASS DMEM_RD
DMEM_LOAD_W
JUMP_TABLE_B
micro_op_end
; //
; ////////////////////////////////////////////////////////////////////////////
; ////////////////////////////////////////////////////////////////////////////
; STORE ADDRESSING MODES
; ////////////////////////////////////////////////////////////////////////////
; //
ST_INDEXED:
decode pg1_JTA ST_INDEXED $6F ; CLR(idx)
; //
decode pg1_JTA ST_INDEXED $6E ; JMP(idx)
; //
decode pg1_JTA ST_INDEXED $AD ; JSR (idx)
; //
decode pg1_JTA ST_INDEXED $32 ; LEAS(inh)
decode pg1_JTA ST_INDEXED $33 ; LEAU(inh)
decode pg1_JTA ST_INDEXED $30 ; LEAX(inh)
decode pg1_JTA ST_INDEXED $31 ; LEAY(inh)
; //
decode pg1_JTA ST_INDEXED $A7 ; STA (idx)
decode pg1_JTA ST_INDEXED $E7 ; STB (idx)
decode pg1_JTA ST_INDEXED $ED ; STD (idx)
decode pg2_JTA ST_INDEXED $EF ; STS (idx)
decode pg1_JTA ST_INDEXED $EF ; STU (idx)
decode pg1_JTA ST_INDEXED $AF ; STX (idx)
decode pg2_JTA ST_INDEXED $AF ; STY (idx)
SET_DATA_WIDTH W_R1_OR_IND
ADDR_INX_OR_LOAD_IND
IF NOT_INDIRECT
JUMP_TABLE_B
micro_op_end
ST_INDIRECT:
DATA_PASS_B DMEM_RD
DATA_WRITE EA
JUMP_TABLE_B
micro_op_end
; //
; ////////////////////////////////////////////////////////////////////////////
; ////////////////////////////////////////////////////////////////////////////
; INHERENT INSTRUCTIONS
; ////////////////////////////////////////////////////////////////////////////
; //
; //////////////////////////////////////////// ABX
; //
ABX:
decode pg1_JTA ABX $3A ; ABX(inh)
decode pg1_R1 X $3A ; ABX(inh)
decode pg1_R2 B $3A ; ABX(inh)
DATA_ADD R1, R2
DATA_WRITE R1
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// EXG
; //
EXG:
decode pg1_JTA EXG $1E ; EXG(inh)
; R1 = postbyte[7:0] $1E ; EXG(inh)
; R2 = postbyte[3:0] $1E ; EXG(inh)
DATA_PASS_A R1
DATA_WRITE EA
micro_op_end
DATA_PASS_A R2
DATA_WRITE R1
CCR_OP_W OP_XXXXXXXX ; Just in case CCR is destination
micro_op_end
DATA_PASS_A EA
DATA_WRITE R2
CCR_OP_W OP_XXXXXXXX ; Just in case CCR is destination
JUMP GO_NEW_PC ; Just in case PC is destination
micro_op_end
; //////////////////////////////////////////// LEA S or U
; //
LEA_SU:
decode pg1_JTB LEA_SU $32 ; LEAS(inh)
decode pg1_R1 S $32 ; LEAS(inh)
decode pg1_JTB LEA_SU $33 ; LEAU(inh)
decode pg1_R1 U $33 ; LEAU(inh)
DATA_PASS_B EA
DATA_WRITE R1
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// LEA X or Y
; //
LEA_XY:
decode pg1_JTB LEA_XY $30 ; LEAX(inh)
decode pg1_R1 X $30 ; LEAX(inh)
decode pg1_JTB LEA_XY $31 ; LEAY(inh)
decode pg1_R1 Y $31 ; LEAY(inh)
DATA_PASS_B EA
DATA_WRITE R1
SET_DATA_WIDTH W_R1
CCR_OP_W OP_oooooXoo
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// NOP
; //
; // Prebytes are sent here if the execute stage has nothing
; // else better to do. However, this is unnecessary given
; // prebyte processing logic is contained in the decode stage
; // and prebytes are decoded independently without delay if
; // the execute stage is busy. It's called pipelining ;-)
; //
NOP:
decode pg1_JTA NOP $12 ; NOP(inh)
decode pg1_JTA NOP $11 ; page3 (prebyte)
decode pg1_JTA NOP $10 ; page2 (prebyte)
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// EMUL EMULS IDIV EDIV EDIVS IDIVS FDIV
; //
SAU16:
decode pg1_JTA SAU16 $14 ; EMUL (inh)
decode pg1_R2 Y $14 ; EMUL (inh)
decode pg1_R1 D $14 ; EMUL (inh)
decode pg1_JTA SAU16 $15 ; EMULS (inh)
decode pg1_R2 Y $15 ; EMULS (inh)
decode pg1_R1 D $15 ; EMULS (inh)
decode pg1_JTA SAU16 $18 ; IDIV (inh)
decode pg1_R2 D $18 ; IDIV (inh)
decode pg1_R1 X $18 ; IDIV (inh)
decode pg2_JTA SAU16 $19 ; FDIV (inh)
decode pg2_R2 D $19 ; FDIV (inh)
decode pg2_R1 X $19 ; FDIV (inh)
decode pg2_JTA SAU16 $18 ; IDIVS (inh)
decode pg2_R2 D $18 ; IDIVS (inh)
decode pg2_R1 X $18 ; IDIVS (inh)
DATA_SAU_EN
IF SAU_NOT_DONE
JUMP SAU16
micro_op_end
SAU16_DONE:
DATA_SAU_EN
DATA_SAU_DONE
DATA_WRITE R2
JUMP SAU8_DONE
micro_op_end
; //////////////////////////////////////////// DAA MUL
; //
SAU8:
decode pg1_JTA SAU8 $19 ; DAA (inh)
decode pg1_R1 D $19 ; DAA (inh)
decode pg1_JTA SAU8 $3D ; MUL (inh)
decode pg1_R1 D $3D ; MUL (inh)
DATA_SAU_EN
IF SAU_NOT_DONE
JUMP SAU8
micro_op_end
SAU8_DONE:
DATA_SAU_EN
DATA_SAU_DONE
DATA_WRITE R1
CCR_OP_W OP_ooooXXXX ; SAU masks correct bits
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// SEX (in 1 micro-cycle!)
; //
SEX:
decode pg1_JTA SEX $1D ; SEX(inh)
decode pg1_R1 D $1D ; SEX(inh)
decode pg1_R2 SEXB $1D ; SEX(inh)
DATA_PASS_B R2
DATA_WRITE R1
SET_DATA_WIDTH W_R1
CCR_OP_W OP_ooooXXXo ; INFO Prog Man says V unaffected, datasheet says v=0
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// CPY
; //
CPY:
decode pg2_JTA CPY $1F ; CPY (inh)
; R1 = postbyte[7:0] $1F ; CPY (inh)
; R2 = postbyte[3:0] $1F ; CPY (inh)
; TODO INFO: could combine this state with SAU states
DATA_SAU_EN ; initalize byte counter from D register
micro_op_end
CPY_LOOP:
DATA_SAU_EN ; enable byte counter
SET_DATA_WIDTH W_8
ADDR_PASS RR1_WR2
DMEM_LOAD_W
IF SAU_DONE
JUMP GO_NEW_PC
micro_op_end
DATA_SAU_EN ; enable byte counter
SET_DATA_WIDTH W_8
DATA_PASS_B DMEM_RD
ADDR_PASS RR1_WR2
DMEM_STORE_W
JUMP CPY_LOOP
micro_op_end
; //////////////////////////////////////////// TFR
; //
TFR:
decode pg1_JTA TFR $1F ; TFR(inh)
; R1 = postbyte[7:0] $1F ; TFR(inh)
; R2 = postbyte[3:0] $1F ; TFR(inh)
DATA_PASS_A R1
DATA_WRITE R2
CCR_OP_W OP_XXXXXXXX ; Just in case CCR is destination
JUMP GO_NEW_PC ; Just in case PC is destination
micro_op_end
; //
; ////////////////////////////////////////////////////////////////////////////
; ////////////////////////////////////////////////////////////////////////////
; LOAD TYPE INSTRUCTIONS
; ////////////////////////////////////////////////////////////////////////////
; //////////////////////////////////////////// ADC
; //
ADC:
decode pg1_JTA ADC $89 ; ADCA (imm)
decode pg1_R1 A $89 ; ADCA (imm)
decode pg1_R2 IDATA $89 ; ADCA (imm)
decode pg1_JTA ADC $C9 ; ADCB (imm)
decode pg1_R1 B $C9 ; ADCB (imm)
decode pg1_R2 IDATA $C9 ; ADCB (imm)
decode pg1_JTB ADC $99 $A9 $B9 ; ADCA (dir idx ext)
decode pg1_R1 A $99 $A9 $B9 ; ADCA (dir idx ext)
decode pg1_R2 DMEM_RD $99 $A9 $B9 ; ADCA (dir idx ext)
decode pg1_JTB ADC $D9 $E9 $F9 ; ADCB (dir idx ext)
decode pg1_R1 B $D9 $E9 $F9 ; ADCB (dir idx ext)
decode pg1_R2 DMEM_RD $D9 $E9 $F9 ; ADCB (dir idx ext)
DATA_ADDC R1, R2
DATA_WRITE R1
SET_DATA_WIDTH W_R1
CCR_OP_W OP_ooXoXXXX ; H is masked for 16bit
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// ADD
; //
ADD:
decode pg1_JTA ADD $8B ; ADDA (imm)
decode pg1_R1 A $8B ; ADDA (imm)
decode pg1_R2 IDATA $8B ; ADDA (imm)
decode pg1_JTA ADD $CB ; ADDB (imm)
decode pg1_R1 B $CB ; ADDB (imm)
decode pg1_R2 IDATA $CB ; ADDB (imm)
decode pg1_JTA ADD $C3 ; ADDD (imm)
decode pg1_R1 D $C3 ; ADDD (imm)
decode pg1_R2 IDATA $C3 ; ADDD (imm)
decode pg1_JTB ADD $9B $AB $BB ; ADDA (dir idx ext)
decode pg1_R1 A $9B $AB $BB ; ADDA (dir idx ext)
decode pg1_R2 DMEM_RD $9B $AB $BB ; ADDA (dir idx ext)
decode pg1_JTB ADD $DB $EB $FB ; ADDB (dir idx ext)
decode pg1_R1 B $DB $EB $FB ; ADDB (dir idx ext)
decode pg1_R2 DMEM_RD $DB $EB $FB ; ADDB (dir idx ext)
decode pg1_JTB ADD $D3 $E3 $F3 ; ADDD (dir idx ext)
decode pg1_R1 D $D3 $E3 $F3 ; ADDD (dir idx ext)
decode pg1_R2 DMEM_RD $D3 $E3 $F3 ; ADDD (dir idx ext)
DATA_ADD R1, R2
DATA_WRITE R1
SET_DATA_WIDTH W_R1
CCR_OP_W OP_ooXoXXXX ; H is masked for 16bit
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// AND
; //
AND:
decode pg1_JTA AND $84 ; ANDA (imm)
decode pg1_R1 A $84 ; ANDA (imm)
decode pg1_R2 IDATA $84 ; ANDA (imm)
decode pg1_JTA AND $C4 ; ANDB (imm)
decode pg1_R1 B $C4 ; ANDB (imm)
decode pg1_R2 IDATA $C4 ; ANDB (imm)
decode pg1_JTB AND $94 $A4 $B4 ; ANDA (dir idx ext)
decode pg1_R1 A $94 $A4 $B4 ; ANDA (dir idx ext)
decode pg1_R2 DMEM_RD $94 $A4 $B4 ; ANDA (dir idx ext)
decode pg1_JTB AND $D4 $E4 $F4 ; ANDB (dir idx ext)
decode pg1_R1 B $D4 $E4 $F4 ; ANDB (dir idx ext)
decode pg1_R2 DMEM_RD $D4 $E4 $F4 ; ANDB (dir idx ext)
DATA_AND R1, R2
DATA_WRITE R1
SET_DATA_WIDTH W_R1
CCR_OP_W OP_ooooXXXo
JUMP_TABLE_A_NEXT_PC
micro_op_end
ANDCC:
decode pg1_JTA ANDCC $1C ; ANDCC (imm)
decode pg1_R1 CCR $1C ; ANDCC (imm)
decode pg1_R2 IDATA $1C ; ANDCC (imm)
DATA_AND R1, R2
DATA_WRITE R1
SET_DATA_WIDTH W_R1
CCR_OP_W OP_XXXXXXXX
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// BIT
; //
BIT:
decode pg1_JTA BIT $85 ; BITA (imm)
decode pg1_R1 A $85 ; BITA (imm)
decode pg1_R2 IDATA $85 ; BITA (imm)
decode pg1_JTA BIT $C5 ; BITB (imm)
decode pg1_R1 B $C5 ; BITB (imm)
decode pg1_R2 IDATA $C5 ; BITB (imm)
decode pg1_JTB BIT $95 $A5 $B5 ; BITA (dir idx ext)
decode pg1_R1 A $95 $A5 $B5 ; BITA (dir idx ext)
decode pg1_R2 DMEM_RD $95 $A5 $B5 ; BITA (dir idx ext)
decode pg1_JTB BIT $D5 $E5 $F5 ; BITB (dir idx ext)
decode pg1_R1 B $D5 $E5 $F5 ; BITB (dir idx ext)
decode pg1_R2 DMEM_RD $D5 $E5 $F5 ; BITB (dir idx ext)
DATA_AND R1, R2
SET_DATA_WIDTH W_R1
CCR_OP_W OP_ooooXXXo
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// CMP
; //
CMP:
decode pg1_JTA CMP $81 ; CMPA (imm)
decode pg1_R1 A $81 ; CMPA (imm)
decode pg1_R2 IDATA $81 ; CMPA (imm)
decode pg1_JTA CMP $C1 ; CMPB (imm)
decode pg1_R1 B $C1 ; CMPB (imm)
decode pg1_R2 IDATA $C1 ; CMPB (imm)
decode pg2_JTA CMP $83 ; CMPD (imm)
decode pg2_R1 D $83 ; CMPD (imm)
decode pg2_R2 IDATA $83 ; CMPD (imm)
decode pg3_JTA CMP $8C ; CMPS (imm)
decode pg3_R1 S $8C ; CMPS (imm)
decode pg3_R2 IDATA $8C ; CMPS (imm)
decode pg3_JTA CMP $83 ; CMPU (imm)
decode pg3_R1 U $83 ; CMPU (imm)
decode pg3_R2 IDATA $83 ; CMPU (imm)
decode pg1_JTA CMP $8C ; CMPX (imm)
decode pg1_R1 X $8C ; CMPX (imm)
decode pg1_R2 IDATA $8C ; CMPX (imm)
decode pg2_JTA CMP $8C ; CMPY (imm)
decode pg2_R1 Y $8C ; CMPY (imm)
decode pg2_R2 IDATA $8C ; CMPY (imm)
decode pg1_JTB CMP $91 $A1 $B1 ; CMPA (dir idx ext)
decode pg1_R1 A $91 $A1 $B1 ; CMPA (dir idx ext)
decode pg1_R2 DMEM_RD $91 $A1 $B1 ; CMPA (dir idx ext)
decode pg1_JTB CMP $D1 $E1 $F1 ; CMPB (dir idx ext)
decode pg1_R1 B $D1 $E1 $F1 ; CMPB (dir idx ext)
decode pg1_R2 DMEM_RD $D1 $E1 $F1 ; CMPB (dir idx ext)
decode pg2_JTB CMP $93 $A3 $B3 ; CMPD (dir idx ext)
decode pg2_R1 D $93 $A3 $B3 ; CMPD (dir idx ext)
decode pg2_R2 DMEM_RD $93 $A3 $B3 ; CMPD (dir idx ext)
decode pg3_JTB CMP $9C $AC $BC ; CMPS (dir idx ext)
decode pg3_R1 S $9C $AC $BC ; CMPS (dir idx ext)
decode pg3_R2 DMEM_RD $9C $AC $BC ; CMPS (dir idx ext)
decode pg3_JTB CMP $93 $A3 $B3 ; CMPU (dir idx ext)
decode pg3_R1 U $93 $A3 $B3 ; CMPU (dir idx ext)
decode pg3_R2 DMEM_RD $93 $A3 $B3 ; CMPU (dir idx ext)
decode pg1_JTB CMP $9C $AC $BC ; CMPX (dir idx ext)
decode pg1_R1 X $9C $AC $BC ; CMPX (dir idx ext)
decode pg1_R2 DMEM_RD $9C $AC $BC ; CMPX (dir idx ext)
decode pg2_JTB CMP $9C $AC $BC ; CMPY (dir idx ext)
decode pg2_R1 Y $9C $AC $BC ; CMPY (dir idx ext)
decode pg2_R2 DMEM_RD $9C $AC $BC ; CMPY (dir idx ext)
DATA_SUB R1, R2
SET_DATA_WIDTH W_R1
CCR_OP_W OP_ooooXXXX ; INFO: Spec H Undefined, Turbo9 H not affected
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// EOR
; //
EOR:
decode pg1_JTA EOR $88 ; EORA (imm)
decode pg1_R1 A $88 ; EORA (imm)
decode pg1_R2 IDATA $88 ; EORA (imm)
decode pg1_JTA EOR $C8 ; EORB (imm)
decode pg1_R1 B $C8 ; EORB (imm)
decode pg1_R2 IDATA $C8 ; EORB (imm)
decode pg1_JTB EOR $98 $A8 $B8 ; EORA (dir idx ext)
decode pg1_R1 A $98 $A8 $B8 ; EORA (dir idx ext)
decode pg1_R2 DMEM_RD $98 $A8 $B8 ; EORA (dir idx ext)
decode pg1_JTB EOR $D8 $E8 $F8 ; EORB (dir idx ext)
decode pg1_R1 B $D8 $E8 $F8 ; EORB (dir idx ext)
decode pg1_R2 DMEM_RD $D8 $E8 $F8 ; EORB (dir idx ext)
DATA_XOR R1, R2
DATA_WRITE R1
SET_DATA_WIDTH W_R1
CCR_OP_W OP_ooooXXXo
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// LD
; //
LD:
decode pg1_JTA LD $86 ; LDA (imm)
decode pg1_R1 A $86 ; LDA (imm)
decode pg1_R2 IDATA $86 ; LDA (imm)
decode pg1_JTA LD $C6 ; LDB (imm)
decode pg1_R1 B $C6 ; LDB (imm)
decode pg1_R2 IDATA $C6 ; LDB (imm)
decode pg1_JTA LD $CC ; LDD (imm)
decode pg1_R1 D $CC ; LDD (imm)
decode pg1_R2 IDATA $CC ; LDD (imm)
decode pg2_JTA LD $CE ; LDS (imm)
decode pg2_R1 S $CE ; LDS (imm)
decode pg2_R2 IDATA $CE ; LDS (imm)
decode pg1_JTA LD $CE ; LDU (imm)
decode pg1_R1 U $CE ; LDU (imm)
decode pg1_R2 IDATA $CE ; LDU (imm)
decode pg1_JTA LD $8E ; LDX (imm)
decode pg1_R1 X $8E ; LDX (imm)
decode pg1_R2 IDATA $8E ; LDX (imm)
decode pg2_JTA LD $8E ; LDY (imm)
decode pg2_R1 Y $8E ; LDY (imm)
decode pg2_R2 IDATA $8E ; LDY (imm)
decode pg1_JTB LD $96 $A6 $B6 ; LDA (dir idx ext)
decode pg1_R1 A $96 $A6 $B6 ; LDA (dir idx ext)
decode pg1_R2 DMEM_RD $96 $A6 $B6 ; LDA (dir idx ext)
decode pg1_JTB LD $D6 $E6 $F6 ; LDB (dir idx ext)
decode pg1_R1 B $D6 $E6 $F6 ; LDB (dir idx ext)
decode pg1_R2 DMEM_RD $D6 $E6 $F6 ; LDB (dir idx ext)
decode pg1_JTB LD $DC $EC $FC ; LDD (dir idx ext)
decode pg1_R1 D $DC $EC $FC ; LDD (dir idx ext)
decode pg1_R2 DMEM_RD $DC $EC $FC ; LDD (dir idx ext)
decode pg2_JTB LD $DE $EE $FE ; LDS (dir idx ext)
decode pg2_R1 S $DE $EE $FE ; LDS (dir idx ext)
decode pg2_R2 DMEM_RD $DE $EE $FE ; LDS (dir idx ext)
decode pg1_JTB LD $DE $EE $FE ; LDU (dir idx ext)
decode pg1_R1 U $DE $EE $FE ; LDU (dir idx ext)
decode pg1_R2 DMEM_RD $DE $EE $FE ; LDU (dir idx ext)
decode pg1_JTB LD $9E $AE $BE ; LDX (dir idx ext)
decode pg1_R1 X $9E $AE $BE ; LDX (dir idx ext)
decode pg1_R2 DMEM_RD $9E $AE $BE ; LDX (dir idx ext)
decode pg2_JTB LD $9E $AE $BE ; LDY (dir idx ext)
decode pg2_R1 Y $9E $AE $BE ; LDY (dir idx ext)
decode pg2_R2 DMEM_RD $9E $AE $BE ; LDY (dir idx ext)
DATA_PASS_B R2
DATA_WRITE R1
SET_DATA_WIDTH W_R1
CCR_OP_W OP_ooooXXXo
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// OR
; //
OR:
decode pg1_JTA OR $8A ; ORA (imm)
decode pg1_R1 A $8A ; ORA (imm)
decode pg1_R2 IDATA $8A ; ORA (imm)
decode pg1_JTA OR $CA ; ORB (imm)
decode pg1_R1 B $CA ; ORB (imm)
decode pg1_R2 IDATA $CA ; ORB (imm)
decode pg1_JTB OR $9A $AA $BA ; ORA (dir idx ext)
decode pg1_R1 A $9A $AA $BA ; ORA (dir idx ext)
decode pg1_R2 DMEM_RD $9A $AA $BA ; ORA (dir idx ext)
decode pg1_JTB OR $DA $EA $FA ; ORB (dir idx ext)
decode pg1_R1 B $DA $EA $FA ; ORB (dir idx ext)
decode pg1_R2 DMEM_RD $DA $EA $FA ; ORB (dir idx ext)
DATA_OR R1, R2
DATA_WRITE R1
SET_DATA_WIDTH W_R1
CCR_OP_W OP_ooooXXXo
JUMP_TABLE_A_NEXT_PC
micro_op_end
ORCC:
decode pg1_JTA ORCC $1A ; ORCC (imm)
decode pg1_R1 CCR $1A ; ORCC (imm)
decode pg1_R2 IDATA $1A ; ORCC (imm)
DATA_OR R1, R2
DATA_WRITE R1
SET_DATA_WIDTH W_R1
CCR_OP_W OP_XXXXXXXX
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// SBC
; //
SBC:
decode pg1_JTA SBC $82 ; SBCA (imm)
decode pg1_R1 A $82 ; SBCA (imm)
decode pg1_R2 IDATA $82 ; SBCA (imm)
decode pg1_JTA SBC $C2 ; SBCB (imm)
decode pg1_R1 B $C2 ; SBCB (imm)
decode pg1_R2 IDATA $C2 ; SBCB (imm)
decode pg1_JTB SBC $92 $A2 $B2 ; SBCA (dir idx ext)
decode pg1_R1 A $92 $A2 $B2 ; SBCA (dir idx ext)
decode pg1_R2 DMEM_RD $92 $A2 $B2 ; SBCA (dir idx ext)
decode pg1_JTB SBC $D2 $E2 $F2 ; SBCB (dir idx ext)
decode pg1_R1 B $D2 $E2 $F2 ; SBCB (dir idx ext)
decode pg1_R2 DMEM_RD $D2 $E2 $F2 ; SBCB (dir idx ext)
DATA_SUBC R1, R2
DATA_WRITE R1
SET_DATA_WIDTH W_R1
CCR_OP_W OP_ooooXXXX ; INFO: Spec H Undefined, Turbo9 H not affected
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //////////////////////////////////////////// SUB
; //
SUB:
decode pg1_JTA SUB $80 ; SUBA (imm)
decode pg1_R1 A $80 ; SUBA (imm)
decode pg1_R2 IDATA $80 ; SUBA (imm)
decode pg1_JTA SUB $C0 ; SUBB (imm)
decode pg1_R1 B $C0 ; SUBB (imm)
decode pg1_R2 IDATA $C0 ; SUBB (imm)
decode pg1_JTA SUB $83 ; SUBD (imm)
decode pg1_R1 D $83 ; SUBD (imm)
decode pg1_R2 IDATA $83 ; SUBD (imm)
decode pg1_JTB SUB $90 $A0 $B0 ; SUBA (dir idx ext)
decode pg1_R1 A $90 $A0 $B0 ; SUBA (dir idx ext)
decode pg1_R2 DMEM_RD $90 $A0 $B0 ; SUBA (dir idx ext)
decode pg1_JTB SUB $D0 $E0 $F0 ; SUBB (dir idx ext)
decode pg1_R1 B $D0 $E0 $F0 ; SUBB (dir idx ext)
decode pg1_R2 DMEM_RD $D0 $E0 $F0 ; SUBB (dir idx ext)
decode pg1_JTB SUB $93 $A3 $B3 ; SUBD (dir idx ext)
decode pg1_R1 D $93 $A3 $B3 ; SUBD (dir idx ext)
decode pg1_R2 DMEM_RD $93 $A3 $B3 ; SUBD (dir idx ext)
DATA_SUB R1, R2
DATA_WRITE R1
SET_DATA_WIDTH W_R1
CCR_OP_W OP_ooooXXXX ; INFO: Spec H Undefined, Turbo9 H not affected (8-bit)
JUMP_TABLE_A_NEXT_PC
micro_op_end
; //
; ////////////////////////////////////////////////////////////////////////////
; ////////////////////////////////////////////////////////////////////////////
; STORE INSTRUCTIONS
; ////////////////////////////////////////////////////////////////////////////
; //
; //////////////////////////////////////////// ST
; //
ST:
decode pg1_JTA ST $97 $B7 ; STA (dir ext)
decode pg1_R1 A $97 $B7 ; STA (dir ext)
decode pg1_AR IDATA $97 $B7 ; STA (dir ext)
decode pg1_JTA ST $D7 $F7 ; STB (dir ext)
decode pg1_R1 B $D7 $F7 ; STB (dir ext)
decode pg1_AR IDATA $D7 $F7 ; STB (dir ext)
decode pg1_JTA ST $DD $FD ; STD (dir ext)
decode pg1_R1 D $DD $FD ; STD (dir ext)
decode pg1_AR IDATA $DD $FD ; STD (dir ext)
decode pg2_JTA ST $DF $FF ; STS (dir ext)
decode pg2_R1 S $DF $FF ; STS (dir ext)
decode pg2_AR IDATA $DF $FF ; STS (dir ext)
decode pg1_JTA ST $DF $FF ; STU (dir ext)
decode pg1_R1 U $DF $FF ; STU (dir ext)
decode pg1_AR IDATA $DF $FF ; STU (dir ext)
decode pg1_JTA ST $9F $BF ; STX (dir ext)
decode pg1_R1 X $9F $BF ; STX (dir ext)
decode pg1_AR IDATA $9F $BF ; STX (dir ext)
decode pg2_JTA ST $9F $BF ; STY (dir ext)
decode pg2_R1 Y $9F $BF ; STY (dir ext)
decode pg2_AR IDATA $9F $BF ; STY (dir ext)
decode pg1_JTB ST $A7 ; STA (idx)
decode pg1_R1 A $A7 ; STA (idx)
decode pg1_AR EA $A7 ; STA (idx)
decode pg1_JTB ST $E7 ; STB (idx)