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
|
#include <string.h>
#include "decode.h"
#include "priv.h"
static InstructionId Decode16Vle0x00(uint16_t word16, uint32_t decodeFlags)
{
switch (word16) {
case 0x0000:
return PPC_ID_VLE_SE_ILLEGAL;
case 0x0001:
return PPC_ID_VLE_SE_ISYNC;
case 0x0002:
return PPC_ID_VLE_SE_SC;
case 0x0004:
case 0x0005:
return PPC_ID_VLE_SE_BLRx;
case 0x0006:
case 0x0007:
return PPC_ID_VLE_SE_BCTRx;
case 0x0008:
return PPC_ID_VLE_SE_RFI;
case 0x0009:
return PPC_ID_VLE_SE_RFCI;
case 0x000a:
return PPC_ID_VLE_SE_RFDI;
case 0x000b:
return PPC_ID_VLE_SE_RFMCI;
default:
;
}
uint32_t subop = (word16 >> 4) & 0xfff;
switch (subop) {
case 0x002:
return PPC_ID_VLE_SE_NOT;
case 0x003:
return PPC_ID_VLE_SE_NEG;
case 0x008:
return PPC_ID_VLE_SE_MFLR;
case 0x009:
return PPC_ID_VLE_SE_MTLR;
case 0x00a:
return PPC_ID_VLE_SE_MFCTR;
case 0x00b:
return PPC_ID_VLE_SE_MTCTR;
case 0x00c:
return PPC_ID_VLE_SE_EXTZB;
case 0x00d:
return PPC_ID_VLE_SE_EXTSB;
case 0x00e:
return PPC_ID_VLE_SE_EXTZH;
case 0x00f:
return PPC_ID_VLE_SE_EXTSH;
default:
return PPC_ID_INVALID;;
}
}
static InstructionId Decode16Vle(uint16_t word16, uint32_t decodeFlags)
{
uint8_t hi = (word16 >> 8) & 0xff;
switch (hi) {
case 0x00:
return Decode16Vle0x00(word16, decodeFlags);
case 0x01:
return PPC_ID_VLE_SE_MR;
case 0x02:
return PPC_ID_VLE_SE_MTAR;
case 0x03:
return PPC_ID_VLE_SE_MFAR;
case 0x04:
return PPC_ID_VLE_SE_ADD;
case 0x05:
return PPC_ID_VLE_SE_MULLW;
case 0x06:
return PPC_ID_VLE_SE_SUB;
case 0x07:
return PPC_ID_VLE_SE_SUBF;
case 0x0c:
return PPC_ID_VLE_SE_CMP;
case 0x0d:
return PPC_ID_VLE_SE_CMPL;
case 0x0e:
return PPC_ID_VLE_SE_CMPH;
case 0x0f:
return PPC_ID_VLE_SE_CMPHL;
case 0x20:
case 0x21:
return PPC_ID_VLE_SE_ADDI;
case 0x22:
case 0x23:
return PPC_ID_VLE_SE_CMPLI;
case 0x24:
case 0x25:
case 0x26:
case 0x27:
return PPC_ID_VLE_SE_SUBIx;
case 0x2a:
case 0x2b:
return PPC_ID_VLE_SE_CMPI;
case 0x2c:
case 0x2d:
return PPC_ID_VLE_SE_BMASKI;
case 0x2e:
case 0x2f:
return PPC_ID_VLE_SE_ANDI;
case 0x40:
return PPC_ID_VLE_SE_SRW;
case 0x41:
return PPC_ID_VLE_SE_SRAW;
case 0x42:
return PPC_ID_VLE_SE_SLW;
case 0x44:
{
// rY = 0, rX = 0
// Not technically documented, but compiler
// occasionally emits `or, r0, r0`, which are NOPs in
// 32-bit land
if ((word16 & 0xff) == 0x00)
return PPC_ID_VLE_SE_NOP;
else
return PPC_ID_VLE_SE_OR;
}
case 0x45:
return PPC_ID_VLE_SE_ANDC;
case 0x46:
case 0x47:
return PPC_ID_VLE_SE_ANDx;
case 0x48:
case 0x49:
case 0x4a:
case 0x4b:
case 0x4c:
case 0x4d:
case 0x4e:
case 0x4f:
return PPC_ID_VLE_SE_LI;
case 0x60:
case 0x61:
return PPC_ID_VLE_SE_BCLRI;
case 0x62:
case 0x63:
return PPC_ID_VLE_SE_BGENI;
case 0x64:
case 0x65:
return PPC_ID_VLE_SE_BSETI;
case 0x66:
case 0x67:
return PPC_ID_VLE_SE_BTSTI;
case 0x68:
case 0x69:
return PPC_ID_VLE_SE_SRWI;
case 0x6a:
case 0x6b:
return PPC_ID_VLE_SE_SRAWI;
case 0x6c:
case 0x6d:
return PPC_ID_VLE_SE_SLWI;
case 0x80:
case 0x81:
case 0x82:
case 0x83:
case 0x84:
case 0x85:
case 0x86:
case 0x87:
case 0x88:
case 0x89:
case 0x8a:
case 0x8b:
case 0x8c:
case 0x8d:
case 0x8e:
case 0x8f:
return PPC_ID_VLE_SE_LBZ;
case 0x90:
case 0x91:
case 0x92:
case 0x93:
case 0x94:
case 0x95:
case 0x96:
case 0x97:
case 0x98:
case 0x99:
case 0x9a:
case 0x9b:
case 0x9c:
case 0x9d:
case 0x9e:
case 0x9f:
return PPC_ID_VLE_SE_STB;
case 0xa0:
case 0xa1:
case 0xa2:
case 0xa3:
case 0xa4:
case 0xa5:
case 0xa6:
case 0xa7:
case 0xa8:
case 0xa9:
case 0xaa:
case 0xab:
case 0xac:
case 0xad:
case 0xae:
case 0xaf:
return PPC_ID_VLE_SE_LHZ;
case 0xb0:
case 0xb1:
case 0xb2:
case 0xb3:
case 0xb4:
case 0xb5:
case 0xb6:
case 0xb7:
case 0xb8:
case 0xb9:
case 0xba:
case 0xbb:
case 0xbc:
case 0xbd:
case 0xbe:
case 0xbf:
return PPC_ID_VLE_SE_STH;
case 0xc0:
case 0xc1:
case 0xc2:
case 0xc3:
case 0xc4:
case 0xc5:
case 0xc6:
case 0xc7:
case 0xc8:
case 0xc9:
case 0xca:
case 0xcb:
case 0xcc:
case 0xcd:
case 0xce:
case 0xcf:
return PPC_ID_VLE_SE_LWZ;
case 0xd0:
case 0xd1:
case 0xd2:
case 0xd3:
case 0xd4:
case 0xd5:
case 0xd6:
case 0xd7:
case 0xd8:
case 0xd9:
case 0xda:
case 0xdb:
case 0xdc:
case 0xdd:
case 0xde:
case 0xdf:
return PPC_ID_VLE_SE_STW;
case 0xe0:
case 0xe1:
case 0xe2:
case 0xe3:
case 0xe4:
case 0xe5:
case 0xe6:
case 0xe7:
return PPC_ID_VLE_SE_BC;
case 0xe8:
case 0xe9:
return PPC_ID_VLE_SE_Bx;
default:
return PPC_ID_INVALID;
}
}
static uint16_t Get16Rx(uint16_t word16)
{
uint16_t rx = word16 & 0xf;
return rx + ((rx & 0x8) >> 3) * 16;
}
static uint16_t Get16Ry(uint16_t word16)
{
uint16_t ry = (word16 >> 4) & 0xf;
return ry + ((ry & 0x8) >> 3) * 16;
}
static uint16_t Get16Rz(uint16_t word16)
{
uint16_t rz = (word16 >> 4) & 0xf;
return rz + ((rz & 0x8) >> 3) * 16;
}
static void FillOperands16Vle(Instruction* instruction, uint16_t word16, uint64_t address, bool translate)
{
uint16_t rx = Get16Rx(word16);
uint16_t ry = Get16Ry(word16);
uint16_t rz = Get16Rz(word16);
switch (instruction->id)
{
// <op>
case PPC_ID_VLE_SE_ILLEGAL:
case PPC_ID_VLE_SE_ISYNC:
case PPC_ID_VLE_SE_NOP:
case PPC_ID_VLE_SE_RFCI:
case PPC_ID_VLE_SE_RFDI:
case PPC_ID_VLE_SE_RFI:
case PPC_ID_VLE_SE_RFMCI:
case PPC_ID_VLE_SE_SC:
return;
// <op> rX, rY (4-bit) no rc
case PPC_ID_VLE_SE_ADD:
case PPC_ID_VLE_SE_ANDC:
case PPC_ID_VLE_SE_MR:
case PPC_ID_VLE_SE_MULLW:
case PPC_ID_VLE_SE_OR:
case PPC_ID_VLE_SE_SLW:
case PPC_ID_VLE_SE_SRAW:
case PPC_ID_VLE_SE_SRW:
case PPC_ID_VLE_SE_SUB:
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rx));
PushRegister(instruction, PPC_OP_REG_RA, Gpr(ry));
if (translate)
PushRegister(instruction, PPC_OP_REG_RB, Gpr(rx));
break;
case PPC_ID_VLE_SE_SUBF:
// Subtle difference between this and SE_SUB:
// SUB rX, rY --> SUBF rX, rY, rX (rX := rX - rY)
// SUBF rX, rY --> SUBF rX, rX, rY (rX := rY - rX)
if (translate)
{
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rx));
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
PushRegister(instruction, PPC_OP_REG_RB, Gpr(ry));
}
else
{
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rx));
PushRegister(instruction, PPC_OP_REG_RA, Gpr(ry));
}
break;
// <op> rX, rY, comparisons
case PPC_ID_VLE_SE_CMP:
case PPC_ID_VLE_SE_CMPH:
case PPC_ID_VLE_SE_CMPHL:
case PPC_ID_VLE_SE_CMPL:
if (translate)
PushRegister(instruction, PPC_OP_REG_CRFD_IMPLY0, Crf(0));
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
PushRegister(instruction, PPC_OP_REG_RB, Gpr(ry));
break;
// <op> rX, rY (4-bit) with rc
case PPC_ID_VLE_SE_ANDx:
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rx));
PushRegister(instruction, PPC_OP_REG_RA, Gpr(ry));
if (translate)
PushRegister(instruction, PPC_OP_REG_RB, Gpr(rx));
instruction->flags.rc = (word16 & 0x100) != 0;
break;
// <op> rX (4-bit)
case PPC_ID_VLE_SE_EXTSB:
case PPC_ID_VLE_SE_EXTSH:
PushRegister(instruction, PPC_OP_REG_RS, Gpr(rx));
if (translate)
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
break;
// There aren't any non-VLE instructions that correspond
// directly to these, but they can be mimicked by
// ANDI'ing with 0xff and 0xffff directly
// <op> rX (4-bit)
case PPC_ID_VLE_SE_EXTZB:
case PPC_ID_VLE_SE_EXTZH:
if (translate)
{
// ANDI rX, rX, 0xff
PushRegister(instruction, PPC_OP_REG_RS, Gpr(rx));
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
if (instruction->id == PPC_ID_VLE_SE_EXTZB)
PushUIMMValue(instruction, 0xff);
else
PushUIMMValue(instruction, 0xffff);
}
else
{
PushRegister(instruction, PPC_OP_REG_RS, Gpr(rx));
}
break;
case PPC_ID_VLE_SE_NEG:
case PPC_ID_VLE_SE_NOT:
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rx));
if (translate)
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
break;
case PPC_ID_VLE_SE_MFCTR:
case PPC_ID_VLE_SE_MFLR:
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rx));
break;
case PPC_ID_VLE_SE_MTCTR:
case PPC_ID_VLE_SE_MTLR:
PushRegister(instruction, PPC_OP_REG_RS, Gpr(rx));
break;
// <op> rX,UI5
case PPC_ID_VLE_SE_ANDI:
case PPC_ID_VLE_SE_SLWI:
case PPC_ID_VLE_SE_SRAWI:
case PPC_ID_VLE_SE_SRWI:
{
uint16_t ui5 = (word16 >> 4) & 0x1f;
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
if (translate)
PushRegister(instruction, PPC_OP_REG_RS, Gpr(rx));
PushUIMMValue(instruction, ui5);
break;
}
case PPC_ID_VLE_SE_CMPI:
{
uint16_t ui5 = (word16 >> 4) & 0x1f;
if (translate)
PushRegister(instruction, PPC_OP_REG_CRFD_IMPLY0, Crf(0));
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
PushUIMMValue(instruction, ui5);
break;
}
// <op> rX, OIMM (no rc)
case PPC_ID_VLE_SE_ADDI:
{
uint32_t oim5 = (word16 >> 4) & 0x1f;
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rx));
if (translate)
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
PushSIMMValue(instruction, oim5 + 1);
break;
}
// <op> rX, OIMM (no rc)
case PPC_ID_VLE_SE_CMPLI:
{
uint32_t oim5 = (word16 >> 4) & 0x1f;
if (translate)
PushRegister(instruction, PPC_OP_REG_CRFD_IMPLY0, Crf(0));
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
PushUIMMValue(instruction, oim5 + 1);
break;
}
// <op> rX, OIMM (rc)
case PPC_ID_VLE_SE_SUBIx:
{
uint32_t oim5 = (word16 >> 4) & 0x1f;
uint32_t imm5 = oim5 + 1;
bool rc = (word16 >> 9) & 0x1;
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rx));
if (translate)
{
// In non-VLE, SUBI is a pseudo-op for ADDI with
// a negative value
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
PushSIMMValue(instruction, -((int32_t)imm5));
}
else
{
PushSIMMValue(instruction, imm5);
}
instruction->flags.rc = rc;
break;
}
// <op>[l]
case PPC_ID_VLE_SE_BCTRx:
case PPC_ID_VLE_SE_BLRx:
instruction->flags.lk = word16 & 0x1;
break;
// one-off
case PPC_ID_VLE_SE_Bx:
{
bool lk = (word16 >> 8) & 0x1;
uint16_t bd8 = word16 & 0xff;
instruction->flags.lk = lk;
uint64_t target = address + (int32_t)sign_extend(bd8 << 1, 9);
PushLabel(instruction, target);
break;
}
case PPC_ID_VLE_SE_BC:
{
uint16_t bo16 = (word16 >> 10) & 0x1;
uint16_t bi16 = (word16 >> 8) & 0x3;
uint16_t bd8 = word16 & 0xff;
if (translate)
{
// VLEPEM Table 2-6: BO16 Field Encodings
// 0 --> branch if condition false
// 1 --> branch if condition true
//
// PowerPC programming environments 8-7: BO Operand Encodings
// (relevant excerpt)
// 001zy --> branch if condition false
// 011zy --> branch if condition true
//
// VLE doesn't encode hints, so we just map to encodings
// with z and y equal to 0
uint32_t mapped_bo;
switch (bo16) {
case 0: mapped_bo = 0x04; break;
case 1: mapped_bo = 0x0c; break;
default:
// should be unreachable
mapped_bo = 0; // only to silence compiler warning
}
PushUIMMValue(instruction, mapped_bo);
}
else
{
PushUIMMValue(instruction, bo16);
}
PushUIMMValue(instruction, bi16);
uint64_t target = address + (int32_t)sign_extend(bd8 << 1, 9);
PushLabel(instruction, target);
break;
}
case PPC_ID_VLE_SE_BCLRI:
{
// --> PPC_ID_ANDI
uint16_t ui5 = (word16 >> 4) & 0x1f;
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
if (translate)
{
PushRegister(instruction, PPC_OP_REG_RS, Gpr(rx));
PushUIMMValue(instruction, ~(1 << ui5));
}
else
{
PushUIMMValue(instruction, ui5);
}
break;
}
case PPC_ID_VLE_SE_BGENI:
{
// --> PPC_ID_LI
uint16_t ui5 = (word16 >> 4) & 0x1f;
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rx));
if (translate)
{
uint32_t value = (1ul << ui5);
PushUIMMValue(instruction, value);
}
else
{
PushUIMMValue(instruction, ui5);
}
break;
}
case PPC_ID_VLE_SE_BMASKI:
{
// --> PPC_ID_LI
uint16_t ui5 = (word16 >> 4) & 0x1f;
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rx));
if (translate)
{
uint32_t value = ~(1ul << ui5);
PushUIMMValue(instruction, value);
}
else
{
PushUIMMValue(instruction, ui5);
}
break;
}
case PPC_ID_VLE_SE_BSETI:
{
// --> PPC_ID_ORI
uint16_t ui5 = (word16 >> 4) & 0x1f;
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
if (translate)
{
uint32_t value = 1ul << ui5;
PushRegister(instruction, PPC_OP_REG_RS, Gpr(rx));
PushUIMMValue(instruction, value);
}
else
{
PushUIMMValue(instruction, ui5);
}
break;
}
case PPC_ID_VLE_SE_BTSTI:
{
// This instruction isn't expressible in standard powerpc,
// so we don't bother trying to convert it to anything
uint16_t ui5 = (word16 >> 4) & 0x1f;
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
PushUIMMValue(instruction, ui5);
break;
}
// NOTE: LBZ, LHZ, and LWZ in VLE don't turn rX=0 into 0
case PPC_ID_VLE_SE_LBZ:
{
uint32_t sd4 = (word16 >> 8) & 0xf;
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rz));
PushMem(instruction, PPC_OP_MEM_RA, Gpr(rx), (int32_t)sd4);
break;
}
case PPC_ID_VLE_SE_LHZ:
{
uint32_t sd4 = ((word16 >> 8) & 0xf) * 2;
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rz));
PushMem(instruction, PPC_OP_MEM_RA, Gpr(rx), (int32_t)sd4);
break;
}
case PPC_ID_VLE_SE_LI:
{
uint32_t ui7 = (word16 >> 4) & 0x7f;
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rx));
PushUIMMValue(instruction, ui7);
break;
}
case PPC_ID_VLE_SE_LWZ:
{
uint32_t sd4 = ((word16 >> 8) & 0xf) * 4;
PushRegister(instruction, PPC_OP_REG_RD, Gpr(rz));
PushMem(instruction, PPC_OP_MEM_RA, Gpr(rx), (int32_t)sd4);
break;
}
case PPC_ID_VLE_SE_MFAR:
PushRegister(instruction, PPC_OP_REG_RA, Gpr(rx));
PushRegister(instruction, PPC_OP_REG_RS, Gpr(8 + ry));
break;
case PPC_ID_VLE_SE_MTAR:
PushRegister(instruction, PPC_OP_REG_RA, Gpr(8 + rx));
PushRegister(instruction, PPC_OP_REG_RS, Gpr(ry));
break;
// NOTE: STB, STH, and STW in VLE don't turn rX=0 into 0
case PPC_ID_VLE_SE_STB:
{
uint32_t sd4 = (word16 >> 8) & 0xf;
PushRegister(instruction, PPC_OP_REG_RS, Gpr(rz));
PushMem(instruction, PPC_OP_MEM_RA, Gpr(rx), (int32_t)sd4);
break;
}
case PPC_ID_VLE_SE_STH:
{
uint32_t sd4 = ((word16 >> 8) & 0xf) * 2;
PushRegister(instruction, PPC_OP_REG_RS, Gpr(rz));
PushMem(instruction, PPC_OP_MEM_RA, Gpr(rx), (int32_t)sd4);
break;
}
case PPC_ID_VLE_SE_STW:
{
uint32_t sd4 = ((word16 >> 8) & 0xf) * 4;
PushRegister(instruction, PPC_OP_REG_RS, Gpr(rz));
PushMem(instruction, PPC_OP_MEM_RA, Gpr(rx), (int32_t)sd4);
break;
}
default:
;
}
}
bool Decompose16Vle(Instruction* instruction, uint16_t word16, uint64_t address, uint32_t flags)
{
memset(instruction, 0, sizeof *instruction);
instruction->id = Decode16Vle(word16, flags);
if (instruction->id == PPC_ID_INVALID)
return false;
bool translate = (flags & DECODE_FLAGS_VLE_TRANSLATE) != 0;
FillOperands16Vle(instruction, word16, address, translate);
if (translate)
instruction->id = VleTranslateMnemonic(instruction->id);
return true;
}
void FillVle16BcOperands(OperandsList *se_bc, const Instruction *instruction)
{
memset(se_bc, 0, sizeof *se_bc);
if (instruction->id != PPC_ID_VLE_SE_BC)
return;
// se_bc only looks at CR0
se_bc->operands[0].cls = PPC_OP_REG_CRFS_IMPLY0;
se_bc->operands[0].reg = Crf(0);
se_bc->numOperands = 1;
}
|