-
Notifications
You must be signed in to change notification settings - Fork 0
/
sharcdrc.cpp
4912 lines (4322 loc) · 167 KB
/
sharcdrc.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
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
// license:BSD-3-Clause
// copyright-holders:Ville Linde
/******************************************************************************
SHARC UML recompiler core
******************************************************************************/
#include "emu.h"
#include "debugger.h"
#include "sharc.h"
#include "sharcfe.h"
#include "cpu/drcfe.h"
#include "cpu/drcuml.h"
#include "cpu/drcumlsh.h"
using namespace uml;
#define USE_SWAPDQ 1
#define WRITE_SNOOP 0
// map variables
#define MAPVAR_PC M0
#define MAPVAR_CYCLES M1
// exit codes
#define EXECUTE_OUT_OF_CYCLES 0
#define EXECUTE_MISSING_CODE 1
#define EXECUTE_UNMAPPED_CODE 2
#define EXECUTE_RESET_CACHE 3
#define REG(reg) m_regmap[reg]
#define DM_I(reg) mem(&m_core->dag1.i[reg])
#define DM_M(reg) mem(&m_core->dag1.m[reg])
#define DM_L(reg) mem(&m_core->dag1.l[reg])
#define DM_B(reg) mem(&m_core->dag1.b[reg])
#define PM_I(reg) mem(&m_core->dag2.i[reg])
#define PM_M(reg) mem(&m_core->dag2.m[reg])
#define PM_L(reg) mem(&m_core->dag2.l[reg])
#define PM_B(reg) mem(&m_core->dag2.b[reg])
#define ASTAT_AZ mem(&m_core->astat_drc.az)
#define ASTAT_AV mem(&m_core->astat_drc.av)
#define ASTAT_AN mem(&m_core->astat_drc.an)
#define ASTAT_AC mem(&m_core->astat_drc.ac)
#define ASTAT_AS mem(&m_core->astat_drc.as)
#define ASTAT_AI mem(&m_core->astat_drc.ai)
#define ASTAT_AF mem(&m_core->astat_drc.af)
#define ASTAT_MN mem(&m_core->astat_drc.mn)
#define ASTAT_MV mem(&m_core->astat_drc.mv)
#define ASTAT_MU mem(&m_core->astat_drc.mu)
#define ASTAT_MI mem(&m_core->astat_drc.mi)
#define ASTAT_SV mem(&m_core->astat_drc.sv)
#define ASTAT_SZ mem(&m_core->astat_drc.sz)
#define ASTAT_SS mem(&m_core->astat_drc.ss)
#define ASTAT_BTF mem(&m_core->astat_drc.btf)
#define FLAG0 mem(&m_core->flag[0])
#define FLAG1 mem(&m_core->flag[1])
#define FLAG2 mem(&m_core->flag[2])
#define FLAG3 mem(&m_core->flag[3])
#define CURLCNTR mem(&m_core->curlcntr)
#define LCNTR mem(&m_core->lcntr)
#define PCSTK mem(&m_core->pcstk)
#define PCSTKP mem(&m_core->pcstkp)
#define STKY mem(&m_core->stky)
#define LSTKP mem(&m_core->lstkp)
#define USTAT1 mem(&m_core->ustat1)
#define USTAT2 mem(&m_core->ustat2)
#define IRPTL mem(&m_core->irptl)
#define MODE1 mem(&m_core->mode1)
#define MODE2 mem(&m_core->mode2)
#define IMASK mem(&m_core->imask)
#define IMASKP mem(&m_core->imaskp)
#define MRF mem(&m_core->mrf)
#define MRB mem(&m_core->mrb)
//#define ASTAT_CALC_REQUIRED desc->regreq[0] & 0x10000
#define AZ_CALC_REQUIRED ((desc->regreq[0] & 0x00010000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define AV_CALC_REQUIRED ((desc->regreq[0] & 0x00020000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define AN_CALC_REQUIRED ((desc->regreq[0] & 0x00040000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define AC_CALC_REQUIRED ((desc->regreq[0] & 0x00080000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define AS_CALC_REQUIRED ((desc->regreq[0] & 0x00100000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define AI_CALC_REQUIRED ((desc->regreq[0] & 0x00200000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define MN_CALC_REQUIRED ((desc->regreq[0] & 0x00400000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define MV_CALC_REQUIRED ((desc->regreq[0] & 0x00800000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define MU_CALC_REQUIRED ((desc->regreq[0] & 0x01000000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define MI_CALC_REQUIRED ((desc->regreq[0] & 0x02000000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define SV_CALC_REQUIRED ((desc->regreq[0] & 0x04000000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define SZ_CALC_REQUIRED ((desc->regreq[0] & 0x08000000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define SS_CALC_REQUIRED ((desc->regreq[0] & 0x10000000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define BTF_CALC_REQUIRED ((desc->regreq[0] & 0x20000000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define AF_CALC_REQUIRED ((desc->regreq[0] & 0x40000000) || desc->flags & OPFLAG_IN_DELAY_SLOT)
#define IRAM_BLOCK0_START 0x20000
#define IRAM_BLOCK0_END 0x27fff
#define IRAM_BLOCK1_START 0x28000
#define IRAM_BLOCK1_END 0x3ffff
#define IRAM_SHORT_BLOCK0_START 0x40000
#define IRAM_SHORT_BLOCK0_END 0x4ffff
#define IRAM_SHORT_BLOCK1_START 0x50000
#define IRAM_SHORT_BLOCK1_END 0x7ffff
#define IOP_REGISTER_START 0x00000
#define IOP_REGISTER_END 0x000ff
#define IRAM_END 0x7ffff
inline void adsp21062_device::alloc_handle(drcuml_state *drcuml, code_handle **handleptr, const char *name)
{
if (*handleptr == nullptr)
*handleptr = drcuml->handle_alloc(name);
}
static void cfunc_unimplemented(void *param)
{
adsp21062_device *sharc = (adsp21062_device *)param;
sharc->sharc_cfunc_unimplemented();
}
static void cfunc_read_iop(void *param)
{
adsp21062_device *sharc = (adsp21062_device *)param;
sharc->sharc_cfunc_read_iop();
}
static void cfunc_write_iop(void *param)
{
adsp21062_device *sharc = (adsp21062_device *)param;
sharc->sharc_cfunc_write_iop();
}
static void cfunc_pcstack_overflow(void *param)
{
adsp21062_device *sharc = (adsp21062_device *)param;
sharc->sharc_cfunc_pcstack_overflow();
}
static void cfunc_pcstack_underflow(void *param)
{
adsp21062_device *sharc = (adsp21062_device *)param;
sharc->sharc_cfunc_pcstack_underflow();
}
static void cfunc_loopstack_overflow(void *param)
{
adsp21062_device *sharc = (adsp21062_device *)param;
sharc->sharc_cfunc_loopstack_overflow();
}
static void cfunc_loopstack_underflow(void *param)
{
adsp21062_device *sharc = (adsp21062_device *)param;
sharc->sharc_cfunc_loopstack_underflow();
}
static void cfunc_statusstack_overflow(void *param)
{
adsp21062_device *sharc = (adsp21062_device *)param;
sharc->sharc_cfunc_statusstack_overflow();
}
static void cfunc_statusstack_underflow(void *param)
{
adsp21062_device *sharc = (adsp21062_device *)param;
sharc->sharc_cfunc_statusstack_underflow();
}
static void cfunc_unimplemented_compute(void *param)
{
adsp21062_device *sharc = (adsp21062_device *)param;
sharc->sharc_cfunc_unimplemented_compute();
}
static void cfunc_unimplemented_shiftimm(void *param)
{
adsp21062_device *sharc = (adsp21062_device *)param;
sharc->sharc_cfunc_unimplemented_shiftimm();
}
#if WRITE_SNOOP
void adsp21062_device::sharc_cfunc_write_snoop()
{
printf("Write %08X to %08X at %08X\n", m_core->arg0, m_core->arg1, m_core->arg2);
}
static void cfunc_write_snoop(void *param)
{
adsp21062_device *sharc = (adsp21062_device *)param;
sharc->sharc_cfunc_write_snoop();
}
#endif
void adsp21062_device::sharc_cfunc_unimplemented()
{
UINT64 op = m_core->arg64;
fatalerror("PC=%08X: Unimplemented op %04X%08X\n", m_core->pc, (UINT32)(op >> 32), (UINT32)(op));
}
void adsp21062_device::sharc_cfunc_unimplemented_compute()
{
UINT64 op = m_core->arg64;
fatalerror("PC=%08X: Unimplemented compute %04X%08X\n", m_core->pc, (UINT32)(op >> 32), (UINT32)(op));
}
void adsp21062_device::sharc_cfunc_unimplemented_shiftimm()
{
UINT64 op = m_core->arg64;
fatalerror("PC=%08X: Unimplemented shiftimm %04X%08X\n", m_core->pc, (UINT32)(op >> 32), (UINT32)(op));
}
void adsp21062_device::sharc_cfunc_read_iop()
{
m_core->arg1 = sharc_iop_r(m_core->arg0);
}
void adsp21062_device::sharc_cfunc_write_iop()
{
sharc_iop_w(m_core->arg0, m_core->arg1);
}
void adsp21062_device::sharc_cfunc_pcstack_overflow()
{
fatalerror("SHARC: PCStack overflow");
}
void adsp21062_device::sharc_cfunc_pcstack_underflow()
{
fatalerror("SHARC: PCStack underflow");
}
void adsp21062_device::sharc_cfunc_loopstack_overflow()
{
fatalerror("SHARC: Loop Stack overflow");
}
void adsp21062_device::sharc_cfunc_loopstack_underflow()
{
fatalerror("SHARC: Loop Stack underflow");
}
void adsp21062_device::sharc_cfunc_statusstack_overflow()
{
fatalerror("SHARC: Status Stack overflow");
}
void adsp21062_device::sharc_cfunc_statusstack_underflow()
{
fatalerror("SHARC: Status Stack underflow");
}
bool adsp21062_device::if_condition_always_true(int condition)
{
if (condition == 0x1f || condition == 0x1e)
return true;
else
return false;
}
UINT32 adsp21062_device::do_condition_astat_bits(int condition)
{
UINT32 r = 0;
switch (condition)
{
case 0x00: r = AZ; break; // EQ
case 0x01: r = AZ | AN; break; // LT
case 0x02: r = AZ | AN; break; // LE
case 0x03: r = AC; break; // AC
case 0x04: r = AV; break; // AV
case 0x05: r = MV; break; // MV
case 0x06: r = MN; break; // MS
case 0x07: r = SV; break; // SV
case 0x08: r = SZ; break; // SZ
case 0x0d: r = BTF; break; // TF
case 0x10: r = AZ; break; // NOT EQUAL
case 0x11: r = AZ | AN; break; // GE
case 0x12: r = AZ | AN; break; // GT
case 0x13: r = AC; break; // NOT AC
case 0x14: r = AV; break; // NOT AV
case 0x15: r = MV; break; // NOT MV
case 0x16: r = MN; break; // NOT MS
case 0x17: r = SV; break; // NOT SV
case 0x18: r = SZ; break; // NOT SZ
case 0x1d: r = BTF; break; // NOT TF
}
return r;
}
/*-------------------------------------------------
load_fast_iregs - load any fast integer
registers
-------------------------------------------------*/
inline void adsp21062_device::load_fast_iregs(drcuml_block *block)
{
int regnum;
for (regnum = 0; regnum < ARRAY_LENGTH(m_regmap); regnum++)
{
if (m_regmap[regnum].is_int_register())
{
UML_MOV(block, ireg(m_regmap[regnum].ireg() - REG_I0), mem(&m_core->r[regnum]));
}
}
}
/*-------------------------------------------------
save_fast_iregs - save any fast integer
registers
-------------------------------------------------*/
void adsp21062_device::save_fast_iregs(drcuml_block *block)
{
int regnum;
for (regnum = 0; regnum < ARRAY_LENGTH(m_regmap); regnum++)
{
if (m_regmap[regnum].is_int_register())
{
UML_MOV(block, mem(&m_core->r[regnum]), ireg(m_regmap[regnum].ireg() - REG_I0));
}
}
}
void adsp21062_device::static_generate_memory_accessor(MEM_ACCESSOR_TYPE type, const char *name, code_handle *&handleptr)
{
// I0 = read/write data
// I1 = address
// I2 is trashed
void* block0 = &m_internal_ram_block0[0];
void* block0_1 = &m_internal_ram_block0[1];
void* block0_2 = &m_internal_ram_block0[2];
void* block1 = &m_internal_ram_block1[0];
void* block1_1 = &m_internal_ram_block1[1];
void* block1_2 = &m_internal_ram_block1[2];
code_label label = 1;
drcuml_block *block = m_drcuml->begin_block(1024);
// add a global entry for this
alloc_handle(m_drcuml.get(), &handleptr, name);
UML_HANDLE(block, *handleptr); // handle *handleptr
switch (type)
{
case MEM_ACCESSOR_PM_READ48:
UML_CMP(block, I1, IRAM_BLOCK0_START); // cmp i1,IRAM_BLOCK0_START
UML_JMPc(block, COND_B, label); // jb label1
UML_CMP(block, I1, IRAM_BLOCK0_END); // cmp i1,IRAM_BLOCK0_END
UML_JMPc(block, COND_A, label); // ja label1
// 0x20000 ... 0x27fff
UML_AND(block, I1, I1, 0x7fff); // and i1,i1,0x7fff
UML_MULS(block, I1, I1, I1, 3); // muls i1,3
UML_DLOAD(block, I0, block0, I1, SIZE_WORD, SCALE_x2); // dload i0,[block0],i1,word,scale_x2
UML_DSHL(block, I0, I0, 32); // dshl i0,i0,32
UML_DLOAD(block, I2, block0_1, I1, SIZE_WORD, SCALE_x2); // dload i2,[block0_1],i1,word,scale_x2
UML_DSHL(block, I2, I2, 16); // dshl i2,i2,16
UML_DOR(block, I0, I0, I2); // dor i0,i0,i2
UML_DLOAD(block, I2, block0_2, I1, SIZE_WORD, SCALE_x2); // dload i2,[block0_2],i1,word,scale_x2
UML_DOR(block, I0, I0, I2); // dor i0,i0,i2
UML_RET(block); // ret
UML_LABEL(block, label++); // label1:
UML_CMP(block, I1, IRAM_BLOCK1_START); // cmp i1,IRAM_BLOCK1_START
UML_JMPc(block, COND_B, label); // jb label2
UML_CMP(block, I1, IRAM_BLOCK1_END); // cmp i1,IRAM_BLOCK1_END
UML_JMPc(block, COND_A, label); // ja label2
// 0x28000 ... 0x3ffff
UML_AND(block, I1, I1, 0x7fff); // and i1,i1,0x7fff (block 1 is mirrored in 0x28000...2ffff, 0x30000...0x37fff and 0x38000...3ffff)
UML_MULS(block, I1, I1, I1, 3); // muls i1,3
UML_DLOAD(block, I0, block1, I1, SIZE_WORD, SCALE_x2); // dload i0,[block1],i1,word,scale_x2
UML_DSHL(block, I0, I0, 32); // dshl i0,i0,32
UML_DLOAD(block, I2, block1_1, I1, SIZE_WORD, SCALE_x2); // dload i2,[block1_1],i1,word,scale_x2
UML_DSHL(block, I2, I2, 16); // dshl i2,i2,16
UML_DOR(block, I0, I0, I2); // dor i0,i0,i2
UML_DLOAD(block, I2, block1_2, I1, SIZE_WORD, SCALE_x2); // dload i2,[block1_2],i1,word,scale_x2
UML_DOR(block, I0, I0, I2); // dor i0,i0,i2
UML_RET(block); // ret
UML_LABEL(block, label++); // label2:
break;
case MEM_ACCESSOR_PM_WRITE48:
UML_CMP(block, I1, IRAM_BLOCK0_START); // cmp i1,IRAM_BLOCK0_START
UML_JMPc(block, COND_B, label); // jb label1
UML_CMP(block, I1, IRAM_BLOCK0_END); // cmp i1,IRAM_BLOCK0_END
UML_JMPc(block, COND_A, label); // ja label1
// 0x20000 ... 0x27fff
UML_AND(block, I1, I1, 0x7fff); // and i1,i1,0x7fff
UML_MULS(block, I1, I1, I1, 3); // muls i1,3
UML_DSTORE(block, block0_2, I1, I0, SIZE_WORD, SCALE_x2); // dstore [block0_2],i1,i0,word,scale_x2
UML_DSHR(block, I0, I0, 16); // dshr i0,i0,16
UML_DSTORE(block, block0_1, I1, I0, SIZE_WORD, SCALE_x2); // dstore [block0_1],i1,i0,word,scale_x2
UML_DSHR(block, I0, I0, 16); // dshr i0,i0,16
UML_DSTORE(block, block0, I1, I0, SIZE_WORD, SCALE_x2); // dstore [block0],i1,i0,word,scale_x2
UML_MOV(block, mem(&m_core->force_recompile), 1);
UML_RET(block); // ret
UML_LABEL(block, label++); // label1:
UML_CMP(block, I1, IRAM_BLOCK1_START); // cmp i1,IRAM_BLOCK1_START
UML_JMPc(block, COND_B, label); // jb label2
UML_CMP(block, I1, IRAM_BLOCK1_END); // cmp i1,IRAM_BLOCK1_END
UML_JMPc(block, COND_A, label); // ja label2
// 0x28000 ... 0x3ffff
UML_AND(block, I1, I1, 0x7fff); // and i1,i1,0x7fff (block 1 is mirrored in 0x28000...2ffff, 0x30000...0x37fff and 0x38000...3ffff)
UML_MULS(block, I1, I1, I1, 3); // muls i1,3
UML_DSTORE(block, block1_2, I1, I0, SIZE_WORD, SCALE_x2); // dstore [block1_2],i1,i0,word,scale_x2
UML_DSHR(block, I0, I0, 16); // dshr i0,i0,16
UML_DSTORE(block, block1_1, I1, I0, SIZE_WORD, SCALE_x2); // dstore [block1_1],i1,i0,word,scale_x2
UML_DSHR(block, I0, I0, 16); // dshr i0,i0,16
UML_DSTORE(block, block1, I1, I0, SIZE_WORD, SCALE_x2); // dstore [block1],i1,i0,word,scale_x2
UML_RET(block); // ret
UML_LABEL(block, label++); // label2:
break;
case MEM_ACCESSOR_PM_READ32:
UML_CMP(block, I1, IRAM_BLOCK0_START); // cmp i1,IRAM_BLOCK0_START
UML_JMPc(block, COND_B, label); // jb label1
UML_CMP(block, I1, IRAM_BLOCK0_END); // cmp i1,IRAM_BLOCK0_END
UML_JMPc(block, COND_A, label); // ja label1
// 0x20000 ... 0x27fff
UML_AND(block, I1, I1, 0x7fff); // and i1,i1,0x7fff
UML_MULS(block, I1, I1, I1, 3); // muls i1,3
UML_LOAD(block, I0, block0, I1, SIZE_WORD, SCALE_x2); // load i0,[block0],i1,word,scale_x2
UML_SHL(block, I0, I0, 16); // shl i0,i0,16
UML_LOAD(block, I2, block0_1, I1, SIZE_WORD, SCALE_x2); // load i2,[block0_1],i1,word,scale_x2
UML_OR(block, I0, I0, I2); // or i0,i0,i2
UML_RET(block); // ret
UML_LABEL(block, label++); // label1:
UML_CMP(block, I1, IRAM_BLOCK1_START); // cmp i1,IRAM_BLOCK1_START
UML_JMPc(block, COND_B, label); // jb label2
UML_CMP(block, I1, IRAM_BLOCK1_END); // cmp i1,IRAM_BLOCK1_END
UML_JMPc(block, COND_A, label); // ja label2
// 0x28000 ... 0x3ffff
UML_AND(block, I1, I1, 0x7fff); // and i1,i1,0x7fff (block 1 is mirrored in 0x28000...2ffff, 0x30000...0x37fff and 0x38000...3ffff)
UML_MULS(block, I1, I1, I1, 3); // muls i1,3
UML_LOAD(block, I0, block1, I1, SIZE_WORD, SCALE_x2); // load i0,[block1],i1,word,scale_x2
UML_SHL(block, I0, I0, 16); // shl i0,i0,16
UML_LOAD(block, I2, block1_1, I1, SIZE_WORD, SCALE_x2); // load i2,[block1_1],i1,word,scale_x2
UML_OR(block, I0, I0, I2); // or i0,i0,i2
UML_RET(block); // ret
UML_LABEL(block, label++); // label2:
break;
case MEM_ACCESSOR_PM_WRITE32:
UML_CMP(block, I1, IRAM_BLOCK0_START); // cmp i1,IRAM_BLOCK0_START
UML_JMPc(block, COND_B, label); // jb label1
UML_CMP(block, I1, IRAM_BLOCK0_END); // cmp i1,IRAM_BLOCK0_END
UML_JMPc(block, COND_A, label); // ja label1
// 0x20000 ... 0x27fff
UML_AND(block, I1, I1, 0x7fff); // and i1,i1,0x7fff
UML_MULS(block, I1, I1, I1, 3); // muls i1,3
UML_STORE(block, block0_1, I1, I0, SIZE_WORD, SCALE_x2); // store [block0_1],i1,i0,word,scale_x2
UML_SHR(block, I0, I0, 16); // shr i0,i0,16
UML_STORE(block, block0, I1, I0, SIZE_WORD, SCALE_x2); // store [block0],i1,i0,word,scale_x2
UML_RET(block); // ret
UML_LABEL(block, label++); // label1:
UML_CMP(block, I1, IRAM_BLOCK1_START); // cmp i1,IRAM_BLOCK1_START
UML_JMPc(block, COND_B, label); // jb label2
UML_CMP(block, I1, IRAM_BLOCK1_END); // cmp i1,IRAM_BLOCK1_END
UML_JMPc(block, COND_A, label); // ja label2
// 0x28000 ... 0x3ffff
UML_AND(block, I1, I1, 0x7fff); // and i1,i1,0x7fff (block 1 is mirrored in 0x28000...2ffff, 0x30000...0x37fff and 0x38000...3ffff)
UML_MULS(block, I1, I1, I1, 3); // muls i1,3
UML_STORE(block, block1_1, I1, I0, SIZE_WORD, SCALE_x2); // store [block1_1],i1,i0,word,scale_x2
UML_SHR(block, I0, I0, 16); // shr i0,i0,16
UML_STORE(block, block1, I1, I0, SIZE_WORD, SCALE_x2); // store [block1],i1,i0,word,scale_x2
UML_RET(block); // ret
UML_LABEL(block, label++); // label2:
break;
case MEM_ACCESSOR_DM_READ32:
UML_CMP(block, I1, IRAM_END); // cmp i1,IRAM_END
UML_JMPc(block, COND_BE, label); // jbe label1
// 0x80000 ...
UML_SHL(block, I1, I1, 2); // shl i1,i1,2
UML_READ(block, I0, I1, SIZE_DWORD, SPACE_DATA); // read i0,i1,dword,SPACE_DATA
UML_RET(block);
UML_LABEL(block, label++); // label1:
UML_CMP(block, I1, IRAM_BLOCK0_START); // cmp i1,IRAM_BLOCK0_START
UML_JMPc(block, COND_B, label); // jb label2
UML_CMP(block, I1, IRAM_BLOCK0_END); // cmp i1,IRAM_BLOCK0_END
UML_JMPc(block, COND_A, label); // ja label2
// 0x20000 ... 0x27fff
UML_AND(block, I1, I1, 0x7fff); // and i1,i1,0x7fff
UML_LOAD(block, I0, block0, I1, SIZE_WORD, SCALE_x4); // load i0,[block0],i1,word,scale_x4
UML_SHL(block, I0, I0, 16); // shl i0,i0,16
UML_LOAD(block, I2, block0_1, I1, SIZE_WORD, SCALE_x4); // load i2,[block0_1],i1,word,scale_x4
UML_OR(block, I0, I0, I2); // or i0,i0,i2
UML_RET(block);
UML_LABEL(block, label++); // label2:
UML_CMP(block, I1, IRAM_BLOCK1_START); // cmp i1,IRAM_BLOCK1_START
UML_JMPc(block, COND_B, label); // jb label3
UML_CMP(block, I1, IRAM_BLOCK1_END); // cmp i1,IRAM_BLOCK1_END
UML_JMPc(block, COND_A, label); // ja label3
// 0x28000 ... 0x3ffff
UML_AND(block, I1, I1, 0x7fff); // and i1,i1,0x7fff
UML_LOAD(block, I0, block1, I1, SIZE_WORD, SCALE_x4); // load i0,[block1],i1,word,scale_x4
UML_SHL(block, I0, I0, 16); // shl i0,i0,16
UML_LOAD(block, I2, block1_1, I1, SIZE_WORD, SCALE_x4); // load i2,[block1_1],i1,word,scale_x4
UML_OR(block, I0, I0, I2); // or i0,i0,i2
UML_RET(block);
UML_LABEL(block, label++); // Label3:
UML_CMP(block, I1, IOP_REGISTER_END); // cmp i1,IOP_REGISTER_END
UML_JMPc(block, COND_A, label); // ja label4
// IOP registers
UML_MOV(block, mem(&m_core->arg0), I1); // mov [m_core->arg0],i1
UML_CALLC(block, cfunc_read_iop, this); // callc cfunc_read_iop
UML_MOV(block, I0, mem(&m_core->arg1)); // mov i0,[m_core->arg1]
UML_RET(block);
UML_LABEL(block, label++); // label4:
UML_CMP(block, I1, IRAM_SHORT_BLOCK0_START); // cmp i1,IRAM_SHORT_BLOCK0_START
UML_JMPc(block, COND_B, label+1); // jb label6
UML_CMP(block, I1, IRAM_SHORT_BLOCK0_END); // cmp i1,IRAM_SHORT_BLOCK0_END
UML_JMPc(block, COND_A, label+1); // ja label6
// 0x40000 ... 0x4ffff
UML_AND(block, I1, I1, 0xffff); // and i1,i1,0xffff
UML_XOR(block, I1, I1, 1); // xor i1,i1,1
UML_TEST(block, mem(&m_core->mode1), 0x4000); // test [m_core->mode1],0x4000
UML_JMPc(block, COND_Z, label); // jz label5
UML_LOADS(block, I0, block0, I1, SIZE_WORD, SCALE_x2); // loads i0,[block0],i1,word,scale_x2
UML_RET(block);
UML_LABEL(block, label++); // label5:
UML_LOAD(block, I0, block0, I1, SIZE_WORD, SCALE_x2); // load i0,[block0],i1,word,scale_x2
UML_RET(block);
UML_LABEL(block, label++); // label6:
UML_CMP(block, I1, IRAM_SHORT_BLOCK1_START); // cmp i1,IRAM_SHORT_BLOCK1_START
UML_JMPc(block, COND_B, label+1); // jb label8
UML_CMP(block, I1, IRAM_SHORT_BLOCK1_END); // cmp i1,IRAM_SHORT_BLOCK1_END
UML_JMPc(block, COND_A, label+1); // ja label8
// 0x50000 ... 0x7ffff
UML_AND(block, I1, I1, 0xffff); // and i1,i1,0xffff
UML_XOR(block, I1, I1, 1); // xor i1,i1,1
UML_TEST(block, mem(&m_core->mode1), 0x4000); // test [m_core->mode1],0x4000
UML_JMPc(block, COND_Z, label); // jz label7
UML_LOADS(block, I0, block1, I1, SIZE_WORD, SCALE_x2); // loads i0,[block1],i1,word,scale_x2
UML_RET(block);
UML_LABEL(block, label++); // label7:
UML_LOAD(block, I0, block1, I1, SIZE_WORD, SCALE_x2); // load i0,[block1],i1,word,scale_x2
UML_RET(block);
UML_LABEL(block, label++); // label8:
break;
case MEM_ACCESSOR_DM_WRITE32:
#if WRITE_SNOOP
//UML_CMP(block, I1, 0x283eb);
UML_CMP(block, I1, 0x2400047);
UML_JMPc(block, COND_NE, label);
UML_MOV(block, mem(&m_core->arg0), I0);
UML_MOV(block, mem(&m_core->arg1), I1);
UML_MOV(block, mem(&m_core->arg2), mem(&m_core->pc));
UML_CALLC(block, cfunc_write_snoop, this);
UML_LABEL(block, label++);
#endif
UML_CMP(block, I1, IRAM_END); // cmp i1,IRAM_END
UML_JMPc(block, COND_BE, label); // jbe label1
// 0x80000 ...
UML_SHL(block, I1, I1, 2); // shl i1,i1,2
UML_WRITE(block, I1, I0, SIZE_DWORD, SPACE_DATA); // write i1,i0,dword,SPACE_DATA
UML_RET(block);
UML_LABEL(block, label++); // label1:
UML_CMP(block, I1, IRAM_BLOCK0_START); // cmp i1,IRAM_BLOCK0_START
UML_JMPc(block, COND_B, label); // jb label2
UML_CMP(block, I1, IRAM_BLOCK0_END); // cmp i1,IRAM_BLOCK0_END
UML_JMPc(block, COND_A, label); // ja label2
// 0x20000 ... 0x27fff
UML_AND(block, I1, I1, 0x7fff); // and i1,i1,0x7fff
UML_STORE(block, block0_1, I1, I0, SIZE_WORD, SCALE_x4); // store [block0_1],i1,i0,word,scale_x4
UML_SHR(block, I0, I0, 16); // shr i0,i0,16
UML_STORE(block, block0, I1, I0, SIZE_WORD, SCALE_x4); // store [block0],i1,i0,word,scale_x4
UML_RET(block);
UML_LABEL(block, label++); // label2:
UML_CMP(block, I1, IRAM_BLOCK1_START); // cmp i1,IRAM_BLOCK1_START
UML_JMPc(block, COND_B, label); // jb label3
UML_CMP(block, I1, IRAM_BLOCK1_END); // cmp i1,IRAM_BLOCK1_END
UML_JMPc(block, COND_A, label); // ja label3
// 0x28000 ... 0x3ffff
UML_AND(block, I1, I1, 0x7fff); // and i1,i1,0x7fff
UML_STORE(block, block1_1, I1, I0, SIZE_WORD, SCALE_x4); // store [block1_1],i1,i0,word,scale_x4
UML_SHR(block, I0, I0, 16); // shr i0,i0,16
UML_STORE(block, block1, I1, I0, SIZE_WORD, SCALE_x4); // store [block1],i1,i0,word,scale_x4
UML_RET(block);
UML_LABEL(block, label++); // Label3:
UML_CMP(block, I1, IOP_REGISTER_END); // cmp i1,IOP_REGISTER_END
UML_JMPc(block, COND_A, label); // ja label4
// IOP registers
UML_MOV(block, mem(&m_core->arg0), I1); // mov [m_core->arg0],i1
UML_MOV(block, mem(&m_core->arg1), I0); // mov [m_core->arg1],i0
UML_CALLC(block, cfunc_write_iop, this); // callc cfunc_write_iop
UML_RET(block);
UML_LABEL(block, label++); // label4:
UML_CMP(block, I1, IRAM_SHORT_BLOCK0_START); // cmp i1,IRAM_SHORT_BLOCK0_START
UML_JMPc(block, COND_B, label); // jb label5
UML_CMP(block, I1, IRAM_SHORT_BLOCK0_END); // cmp i1,IRAM_SHORT_BLOCK0_END
UML_JMPc(block, COND_A, label); // ja label5
// 0x40000 ... 0x4ffff
UML_AND(block, I1, I1, 0xffff); // and i1,i1,0xffff
UML_XOR(block, I1, I1, 1); // xor i1,i1,1
UML_STORE(block, block0, I1, I0, SIZE_WORD, SCALE_x2); // store [block0],i1,i0,word,scale_x2
UML_RET(block);
UML_LABEL(block, label++); // label5:
UML_CMP(block, I1, IRAM_SHORT_BLOCK1_START); // cmp i1,IRAM_SHORT_BLOCK1_START
UML_JMPc(block, COND_B, label); // jb label6
UML_CMP(block, I1, IRAM_SHORT_BLOCK1_END); // cmp i1,IRAM_SHORT_BLOCK1_END
UML_JMPc(block, COND_A, label); // ja label6
// 0x50000 ... 0x7ffff
UML_AND(block, I1, I1, 0xffff); // and i1,i1,0xffff
UML_XOR(block, I1, I1, 1); // xor i1,i1,1
UML_STORE(block, block1, I1, I0, SIZE_WORD, SCALE_x2); // store [block1],i1,i0,word,scale_x2
UML_RET(block);
UML_LABEL(block, label++); // label6:
break;
}
UML_RET(block);
block->end();
}
void adsp21062_device::static_generate_push_pc()
{
// Push contents of I0 to PC stack
// Trashes I1
code_label label = 1;
drcuml_block *block = m_drcuml->begin_block(32);
// add a global entry for this
alloc_handle(m_drcuml.get(), &m_push_pc, "push_pc");
UML_HANDLE(block, *m_push_pc); // handle *m_push_pc
UML_MOV(block, I1, PCSTKP); // mov i1,PCSTKP
UML_ADD(block, I1, I1, 1); // add i1,i1,1
UML_CMP(block, I1, 32); // cmp i1,32
UML_JMPc(block, COND_L,label); // jl label1
UML_CALLC(block, cfunc_pcstack_overflow, this); // callc cfunc_pcstack_overflow
UML_LABEL(block, label++); // label1:
UML_CMP(block, I1, 0); // cmp i1,0
UML_JMPc(block, COND_E, label); // je label2
UML_AND(block, STKY, STKY, ~0x400000); // and STKY,~0x400000
UML_JMP(block, label + 1); // jmp label3
UML_LABEL(block, label++); // label2:
UML_OR(block, STKY, STKY, 0x400000); // or STKY,0x400000
UML_LABEL(block, label++); // label3:
UML_MOV(block, PCSTK, I0); // mov PCSTK,pc
UML_STORE(block, &m_core->pcstack, I1, I0, SIZE_DWORD, SCALE_x4); // store [m_core->pcstack],i1,i0,dword,scale_x4
UML_MOV(block, PCSTKP, I1); // mov PCSTKP,i1
UML_RET(block);
block->end();
}
void adsp21062_device::static_generate_pop_pc()
{
// Pop PC stack into I0
// Trashes I1
code_label label = 1;
drcuml_block *block = m_drcuml->begin_block(32);
// add a global entry for this
alloc_handle(m_drcuml.get(), &m_pop_pc, "pop_pc");
UML_HANDLE(block, *m_pop_pc); // handle *m_pop_pc
UML_MOV(block, I1, PCSTKP); // mov i0,PCSTKP
UML_LOAD(block, I0, &m_core->pcstack, I1, SIZE_DWORD, SCALE_x4); // load i1,[m_core->pcstack],i0,dword,scale_x4
UML_CMP(block, I1, 0); // cmp i1,0
UML_JMPc(block, COND_NE, label); // jne label1
UML_CALLC(block, cfunc_pcstack_underflow, this); // callc cfunc_pcstack_underflow
UML_LABEL(block, label++); // label1:
UML_SUB(block, I1, I1, 1); // sub i1,i1,1
UML_CMP(block, I1, 0); // cmp i1,0
UML_JMPc(block, COND_E, label); // je label2
UML_AND(block, STKY, STKY, ~0x400000); // and STKY,~0x400000
UML_JMP(block, label + 1); // jmp label3
UML_LABEL(block, label++); // label2:
UML_OR(block, STKY, STKY, 0x400000); // or STKY,0x400000
UML_LABEL(block, label++); // label3:
UML_MOV(block, PCSTKP, I1); // mov PCSTKP,i1
UML_MOV(block, PCSTK, I0); // mov PCSTK,i0
UML_RET(block);
block->end();
}
void adsp21062_device::static_generate_push_loop()
{
// I0 = counter
// I1 = type/condition/addr
// Trashes I2
code_label label = 1;
drcuml_block *block = m_drcuml->begin_block(32);
// add a global entry for this
alloc_handle(m_drcuml.get(), &m_push_loop, "push_loop");
UML_HANDLE(block, *m_push_loop); // handle *m_push_loop
UML_MOV(block, I2, LSTKP); // mov i2,LSTKP
UML_ADD(block, I2, I2, 1); // add i2,1
UML_CMP(block, I2, 6); // cmp i2,6
UML_JMPc(block, COND_L, label); // jl label1
UML_CALLC(block, cfunc_loopstack_overflow, this); // callc cfunc_loopstack_overflow
UML_LABEL(block, label++); // label1:
UML_CMP(block, I2, 0); // cmp i2,0
UML_JMPc(block, COND_E, label); // je label2
UML_AND(block, STKY, STKY, ~0x4000000); // and STKY,~0x4000000
UML_JMP(block, label + 1); // jmp label3
UML_LABEL(block, label++); // label2:
UML_OR(block, STKY, STKY, 0x4000000); // or STKY,0x4000000
UML_LABEL(block, label++); // label3:
UML_STORE(block, m_core->lcstack, I2, I0, SIZE_DWORD, SCALE_x4); // store m_core->lcstack,i2,i0,dword,scale_x4
UML_STORE(block, m_core->lastack, I2, I1, SIZE_DWORD, SCALE_x4); // store m_core->lastack,i2,i1,dword,scale_x4
UML_MOV(block, CURLCNTR, I0); // mov CURLCNTR,i0
UML_MOV(block, LSTKP, I2); // mov LSTKP,i2
UML_RET(block);
block->end();
}
void adsp21062_device::static_generate_pop_loop()
{
// Trashes I0,I2
code_label label = 1;
drcuml_block *block = m_drcuml->begin_block(32);
// add a global entry for this
alloc_handle(m_drcuml.get(), &m_pop_loop, "pop_loop");
UML_HANDLE(block, *m_pop_loop); // handle *m_pop_loop
UML_MOV(block, I2, LSTKP); // mov i2,LSTKP
UML_CMP(block, I2, 0); // cmp i2,0
UML_JMPc(block, COND_NE, label); // jne label1
UML_CALLC(block, cfunc_loopstack_underflow, this); // callc cfunc_loopstack_underflow
UML_LABEL(block, label++); // label1:
UML_SUB(block, I2, I2, 1); // sub i2,i2,1
UML_CMP(block, I2, 0); // cmp i2,0
UML_JMPc(block, COND_E, label); // je label2
UML_AND(block, STKY, STKY, ~0x4000000); // and STKY,~0x4000000
UML_JMP(block, label + 1); // jmp label3
UML_LABEL(block, label++); // label2:
UML_OR(block, STKY, STKY, 0x4000000); // or STKY,0x4000000
UML_LABEL(block, label++); // label3:
UML_LOAD(block, I0, m_core->lcstack, I2, SIZE_DWORD, SCALE_x4); // load i0,m_core->lcstack,i2,dword,scale_x4
UML_MOV(block, CURLCNTR, I0); // mov CURLCNTR,i0
UML_MOV(block, LSTKP, I2); // mov LSTKP,i2
UML_RET(block);
block->end();
}
void adsp21062_device::static_generate_push_status()
{
// Trashes I2
code_label label = 1;
drcuml_block *block = m_drcuml->begin_block(32);
// add a global entry for this
alloc_handle(m_drcuml.get(), &m_push_status, "push_status");
UML_HANDLE(block, *m_push_status); // handle *m_push_status
UML_MOV(block, I2, mem(&m_core->status_stkp)); // mov i2,[status_stkp]
UML_ADD(block, I2, I2, 1); // add i2,1
UML_CMP(block, I2, 5); // cmp i2,5
UML_JMPc(block, COND_L, label); // jl label1
UML_CALLC(block, cfunc_statusstack_overflow, this); // callc cfunc_statusstack_overflow
UML_LABEL(block, label++); // label1:
UML_CMP(block, I2, 0); // cmp i2,0
UML_JMPc(block, COND_E, label); // je label2
UML_AND(block, STKY, STKY, ~0x1000000); // and STKY,~0x1000000
UML_JMP(block, label + 1); // jmp label3
UML_LABEL(block, label++); // label2:
UML_OR(block, STKY, STKY, 0x1000000); // or STKY,0x1000000
UML_LABEL(block, label++); // label3:
UML_MOV(block, mem(&m_core->status_stkp), I2); // mov [status_stkp],i2
//TODO: load MODE1
//TODO: load ASTAT
UML_RET(block);
block->end();
}
void adsp21062_device::static_generate_pop_status()
{
// Trashes I2
code_label label = 1;
drcuml_block *block = m_drcuml->begin_block(32);
// add a global entry for this
alloc_handle(m_drcuml.get(), &m_pop_status, "pop_status");
UML_HANDLE(block, *m_pop_status); // handle *m_pop_status
//TODO: store MODE1
//TODO: store ASTAT
UML_MOV(block, I2, mem(&m_core->status_stkp)); // mov i2,[status_stkp]
UML_CMP(block, I2, 0); // cmp i2,0
UML_JMPc(block, COND_NE, label); // jl label1
UML_CALLC(block, cfunc_statusstack_underflow, this); // callc cfunc_statusstack_underflow
UML_LABEL(block, label++); // label1:
UML_SUB(block, I2, I2, 1); // sub i2,1
UML_CMP(block, I2, 0); // cmp i2,0
UML_JMPc(block, COND_E, label); // je label2
UML_AND(block, STKY, STKY, ~0x1000000); // and STKY,~0x1000000
UML_JMP(block, label + 1); // jmp label3
UML_LABEL(block, label++); // label2:
UML_OR(block, STKY, STKY, 0x1000000); // or STKY,0x1000000
UML_LABEL(block, label++); // label3:
UML_MOV(block, mem(&m_core->status_stkp), I2); // mov [status_stkp],i2
UML_RET(block);
block->end();
}
void adsp21062_device::static_generate_exception(UINT8 exception, const char *name)
{
code_handle *&exception_handle = m_exception[exception];
code_label label = 1;
code_label label_nopush = label++;
/* begin generating */
drcuml_block *block = m_drcuml->begin_block(1024);
/* add a global entry for this */
alloc_handle(m_drcuml.get(), &exception_handle, name);
UML_HANDLE(block, *exception_handle); // handle name
UML_AND(block, I3, mem(&m_core->irq_pending), IMASK); // and i3,[irq_pending],IMASK
UML_TZCNT(block, I3, I3); // tzcnt i3,i3
UML_MOV(block, I2, 1); // mov i2,1
UML_SHL(block, I2, I2, I3); // shl i2,i2,i3
UML_OR(block, IRPTL, IRPTL, I2); // or IRPTL,i2
UML_XOR(block, mem(&m_core->irq_pending), mem(&m_core->irq_pending), I2); // xor [irq_pending],i2
UML_MOV(block, mem(&m_core->active_irq_num), I3); // mov [active_irq_num],i3
UML_MOV(block, mem(&m_core->interrupt_active), 1); // mov [interrupt_active],1
UML_CALLH(block, *m_push_pc); // callh m_push_pc
UML_CMP(block, I3, 6); // cmp i3,6
UML_JMPc(block, COND_L, label_nopush); // jl label_nopush
UML_CMP(block, I3, 8); // cmp i3,8
UML_JMPc(block, COND_G, label_nopush); // jg label_nopush
UML_CALLH(block, *m_push_status); // callh m_push_status
UML_LABEL(block, label_nopush); // label_nopush:
UML_SHL(block, I0, I3, 2); // shl i0,i3,2
UML_ADD(block, I0, I0, 0x20000); // add i0,0x20000
UML_HASHJMP(block, 0, I0, *m_nocode); // hashjmp i0,m_nocode
block->end();
}
void adsp21062_device::static_generate_mode1_ops()
{
drcuml_block *block;
// TODO: these could be further optimized with 64-bit or 128-bit swaps
// e.g SWAP128 instruction (swap 128 bits between 2 memory locations)
block = m_drcuml->begin_block(128);
alloc_handle(m_drcuml.get(), &m_swap_dag1_0_3, "swap_dag1_0_3");
UML_HANDLE(block, *m_swap_dag1_0_3); // handle name
#if !USE_SWAPDQ
for (int i = 0; i < 4; i++)
{
UML_MOV(block, I0, mem(&m_core->dag1.i[i]));
UML_MOV(block, I1, mem(&m_core->dag1_alt.i[i]));
UML_MOV(block, mem(&m_core->dag1.i[i]), I1);
UML_MOV(block, mem(&m_core->dag1_alt.i[i]), I0);
UML_MOV(block, I0, mem(&m_core->dag1.m[i]));
UML_MOV(block, I1, mem(&m_core->dag1_alt.m[i]));
UML_MOV(block, mem(&m_core->dag1.m[i]), I1);
UML_MOV(block, mem(&m_core->dag1_alt.m[i]), I0);
UML_MOV(block, I0, mem(&m_core->dag1.l[i]));
UML_MOV(block, I1, mem(&m_core->dag1_alt.l[i]));
UML_MOV(block, mem(&m_core->dag1.l[i]), I1);
UML_MOV(block, mem(&m_core->dag1_alt.l[i]), I0);
UML_MOV(block, I0, mem(&m_core->dag1.b[i]));
UML_MOV(block, I1, mem(&m_core->dag1_alt.b[i]));
UML_MOV(block, mem(&m_core->dag1.b[i]), I1);
UML_MOV(block, mem(&m_core->dag1_alt.b[i]), I0);
}
#else
UML_SWAPDQ(block, mem(&m_core->dag1.i[0]), mem(&m_core->dag1_alt.i[0]));
UML_SWAPDQ(block, mem(&m_core->dag1.m[0]), mem(&m_core->dag1_alt.m[0]));
UML_SWAPDQ(block, mem(&m_core->dag1.l[0]), mem(&m_core->dag1_alt.l[0]));
UML_SWAPDQ(block, mem(&m_core->dag1.b[0]), mem(&m_core->dag1_alt.b[0]));
#endif
UML_RET(block);
block->end();
block = m_drcuml->begin_block(128);
alloc_handle(m_drcuml.get(), &m_swap_dag1_4_7, "swap_dag1_4_7");
UML_HANDLE(block, *m_swap_dag1_4_7); // handle name
#if !USE_SWAPDQ
for (int i = 4; i < 8; i++)
{
UML_MOV(block, I0, mem(&m_core->dag1.i[i]));
UML_MOV(block, I1, mem(&m_core->dag1_alt.i[i]));
UML_MOV(block, mem(&m_core->dag1.i[i]), I1);
UML_MOV(block, mem(&m_core->dag1_alt.i[i]), I0);
UML_MOV(block, I0, mem(&m_core->dag1.m[i]));
UML_MOV(block, I1, mem(&m_core->dag1_alt.m[i]));
UML_MOV(block, mem(&m_core->dag1.m[i]), I1);
UML_MOV(block, mem(&m_core->dag1_alt.m[i]), I0);
UML_MOV(block, I0, mem(&m_core->dag1.l[i]));
UML_MOV(block, I1, mem(&m_core->dag1_alt.l[i]));
UML_MOV(block, mem(&m_core->dag1.l[i]), I1);
UML_MOV(block, mem(&m_core->dag1_alt.l[i]), I0);
UML_MOV(block, I0, mem(&m_core->dag1.b[i]));
UML_MOV(block, I1, mem(&m_core->dag1_alt.b[i]));
UML_MOV(block, mem(&m_core->dag1.b[i]), I1);
UML_MOV(block, mem(&m_core->dag1_alt.b[i]), I0);
}
#else
UML_SWAPDQ(block, mem(&m_core->dag1.i[4]), mem(&m_core->dag1_alt.i[4]));
UML_SWAPDQ(block, mem(&m_core->dag1.m[4]), mem(&m_core->dag1_alt.m[4]));
UML_SWAPDQ(block, mem(&m_core->dag1.l[4]), mem(&m_core->dag1_alt.l[4]));
UML_SWAPDQ(block, mem(&m_core->dag1.b[4]), mem(&m_core->dag1_alt.b[4]));
#endif
UML_RET(block);
block->end();
block = m_drcuml->begin_block(128);
alloc_handle(m_drcuml.get(), &m_swap_dag2_0_3, "swap_dag2_0_3");
UML_HANDLE(block, *m_swap_dag2_0_3); // handle name
#if !USE_SWAPDQ
for (int i = 0; i < 4; i++)
{
UML_MOV(block, I0, mem(&m_core->dag2.i[i]));
UML_MOV(block, I1, mem(&m_core->dag2_alt.i[i]));
UML_MOV(block, mem(&m_core->dag2.i[i]), I1);
UML_MOV(block, mem(&m_core->dag2_alt.i[i]), I0);
UML_MOV(block, I0, mem(&m_core->dag2.m[i]));