1 :option:::insn-bit-size:16
5 :option:::format-names:I,II,III,IV,V,VI,VII,VIII,IX,X
6 :option:::format-names:XI,XII,XIII
7 :option:::format-names:XIV,XV
8 :option:::format-names:Z
9 :option:::format-names:F_I
10 :option:::format-names:C
15 :option:::multi-sim:true
17 :option:::multi-sim:true
18 :model:::v850e1:v850e1:
19 :option:::multi-sim:true
20 :model:::v850e2:v850e2:
21 :option:::multi-sim:true
22 :model:::v850e2v3:v850e2v3:
23 :option:::multi-sim:true
24 :model:::v850e3v5:v850e3v5:
28 :cache:::unsigned:reg1:RRRRR:(RRRRR)
29 :cache:::unsigned:reg2:rrrrr:(rrrrr)
30 :cache:::unsigned:reg3:wwwww:(wwwww)
31 :cache:::unsigned:reg4:W,WWWW:(W + (WWWW << 1))
33 :cache:::unsigned:vreg1:VVVVV:(VVVVV)
34 :cache:::unsigned:vreg1:VVVV:(VVVV << 1)
35 :cache:::unsigned:vreg2:vvvvv:(vvvvv)
36 :cache:::unsigned:vreg2:vvvv:(vvvv << 1)
37 :cache:::unsigned:vreg3:xxxx:(xxxx << 1)
38 :cache:::unsigned:vreg3:xxxxx:(xxxxx)
39 :cache:::unsigned:imm2:ii:(ii)
40 :cache:::unsigned:imm1:i:(i)
42 :cache:::unsigned:reg1e:RRRR:(RRRR << 1)
43 :cache:::unsigned:reg2e:rrrr:(rrrr << 1)
44 :cache:::unsigned:reg3e:wwww:(wwww << 1)
45 :cache:::unsigned:reg4e:mmmm:(mmmm << 1)
47 :cache:::unsigned:disp4:dddd:(dddd)
48 :cache:::unsigned:disp5:dddd:(dddd << 1)
49 :cache:::unsigned:disp7:ddddddd:ddddddd
50 :cache:::unsigned:disp8:ddddddd:(ddddddd << 1)
51 :cache:::unsigned:disp8:dddddd:(dddddd << 2)
52 :cache:::unsigned:disp9:ddddd,ddd:SEXT32 ((ddddd << 4) + (ddd << 1), 9 - 1)
53 :cache:::unsigned:disp16:dddddddddddddddd:EXTEND16 (dddddddddddddddd)
54 :cache:::unsigned:disp16:ddddddddddddddd: EXTEND16 (ddddddddddddddd << 1)
55 :cache:::unsigned:disp17:d,ddddddddddddddd:SEXT32 (((d <<16) + (ddddddddddddddd << 1)), 17 - 1)
56 :cache:::unsigned:disp22:dddddd,ddddddddddddddd: SEXT32 ((dddddd << 16) + (ddddddddddddddd << 1), 22 - 1)
57 :cache:::unsigned:disp23:ddddddd,dddddddddddddddd: SEXT32 ((ddddddd) + (dddddddddddddddd << 7), 23 - 1)
58 :cache:::unsigned:disp23:dddddd,dddddddddddddddd: SEXT32 ((dddddd << 1) + (dddddddddddddddd << 7), 23 - 1)
60 :cache:::unsigned:imm5:iiiii:SEXT32 (iiiii, 4)
61 :cache:::unsigned:imm6:iiiiii:iiiiii
62 :cache:::unsigned:imm9:iiiii,IIII:SEXT ((IIII << 5) + iiiii, 9 - 1)
63 :cache:::unsigned:imm5:iiii:(32 - (iiii << 1))
64 :cache:::unsigned:simm16:iiiiiiiiiiiiiiii:EXTEND16 (iiiiiiiiiiiiiiii)
65 :cache:::unsigned:uimm16:iiiiiiiiiiiiiiii:iiiiiiiiiiiiiiii
66 :cache:::unsigned:imm32:iiiiiiiiiiiiiiii,IIIIIIIIIIIIIIII:(iiiiiiiiiiiiiiii < 16 + IIIIIIIIIIIIIIII)
67 :cache:::unsigned:uimm32:iiiiiiiiiiiiiiii,dddddddddddddddd:((iiiiiiiiiiiiiiii << 16) + dddddddddddddddd)
69 :cache:::unsigned:vector:iiiii:iiiii
71 :cache:::unsigned:list12:L,LLLLLLLLLLL:((L << 11) + LLLLLLLLLLL)
72 :cache:::unsigned:list18:LLLL,LLLLLLLLLLLL:((LLLL << 12) + LLLLLLLLLLLL)
74 :cache:::unsigned:bit3:bbb:bbb
75 :cache:::unsigned:bit4:bbbb:bbbb
76 :cache:::unsigned:bit13:B,BBB:((B << 3) + BBB)
79 // What do we do with an illegal instruction?
82 sim_io_eprintf (SD, "Illegal instruction at address 0x%lx\n",
84 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
90 rrrrr,001110,RRRRR:I:::add
91 "add r<reg1>, r<reg2>"
96 rrrrr,010010,iiiii:II:::add
105 rrrrr,110000,RRRRR + iiiiiiiiiiiiiiii:VI:::addi
106 "addi <simm16>, r<reg1>, r<reg2>"
108 COMPAT_2 (OP_600 ());
114 rrrrr,111111,RRRRR + wwwww,011101,cccc!13,0:XI:::adf
118 "adf %s<cccc>, r<reg1>, r<reg2>, r<reg3>"
120 int cond = condition_met (cccc);
121 TRACE_ALU_INPUT3 (cond, GR[reg1], GR[reg2]);
122 GR[reg3] = GR[reg1] + GR[reg2] + (cond ? 1 : 0);
123 TRACE_ALU_RESULT1 (GR[reg3]);
129 rrrrr,001010,RRRRR:I:::and
130 "and r<reg1>, r<reg2>"
132 COMPAT_1 (OP_140 ());
138 rrrrr,110110,RRRRR + iiiiiiiiiiiiiiii:VI:::andi
139 "andi <uimm16>, r<reg1>, r<reg2>"
141 COMPAT_2 (OP_6C0 ());
146 // Map condition code to a string
151 case 0xf: return "gt";
152 case 0xe: return "ge";
153 case 0x6: return "lt";
155 case 0x7: return "le";
157 case 0xb: return "h";
158 case 0x9: return "nl";
159 case 0x1: return "l";
161 case 0x3: return "nh";
163 case 0x2: return "e";
165 case 0xa: return "ne";
167 case 0x0: return "v";
168 case 0x8: return "nv";
169 case 0x4: return "n";
170 case 0xc: return "p";
171 /* case 0x1: return "c"; */
172 /* case 0x9: return "nc"; */
173 /* case 0x2: return "z"; */
174 /* case 0xa: return "nz"; */
175 case 0x5: return "r"; /* always */
176 case 0xd: return "sa";
183 ddddd,1011,ddd,cccc:III:::Bcond
187 if ((ddddd == 0x00) && (ddd == 0x00) && (cccc == 0x05)) {
188 // Special case - treat "br *" like illegal instruction
189 sim_engine_halt (SD, CPU, NULL, cia, sim_stopped, SIM_SIGTRAP);
191 cond = condition_met (cccc);
194 TRACE_BRANCH1 (cond);
198 00000111111,d,cccc + ddddddddddddddd,1:VII:::Bcond
199 "breakpoint":((disp17 == 0) && (cccc == 0x05))
205 cond = condition_met (cccc);
208 TRACE_BRANCH_INPUT1 (cond);
209 TRACE_BRANCH_RESULT (nia);
215 rrrrr,11111100000 + wwwww,01101000010:XII:::bsh
221 "bsh r<reg2>, r<reg3>"
224 TRACE_ALU_INPUT1 (GR[reg2]);
226 value = (MOVED32 (GR[reg2], 23, 16, 31, 24)
227 | MOVED32 (GR[reg2], 31, 24, 23, 16)
228 | MOVED32 (GR[reg2], 7, 0, 15, 8)
229 | MOVED32 (GR[reg2], 15, 8, 7, 0));
232 PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
233 if ((value & 0xffff) == 0) PSW |= PSW_Z;
234 if (value & 0x80000000) PSW |= PSW_S;
235 if (((value & 0xff) == 0) || ((value & 0xff00) == 0)) PSW |= PSW_CY;
237 TRACE_ALU_RESULT (GR[reg3]);
243 rrrrr,11111100000 + wwwww,01101000000:XII:::bsw
249 "bsw r<reg2>, r<reg3>"
251 #define WORDHASNULLBYTE(x) (((x) - 0x01010101) & ~(x)&0x80808080)
253 TRACE_ALU_INPUT1 (GR[reg2]);
257 value |= (GR[reg2] << 24);
258 value |= ((GR[reg2] << 8) & 0x00ff0000);
259 value |= ((GR[reg2] >> 8) & 0x0000ff00);
262 PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
264 if (value == 0) PSW |= PSW_Z;
265 if (value & 0x80000000) PSW |= PSW_S;
266 if (WORDHASNULLBYTE (value)) PSW |= PSW_CY;
268 TRACE_ALU_RESULT (GR[reg3]);
274 0000001000,iiiiii:II:::callt
286 adr = (CTBP & ~1) + (imm6 << 1);
287 off = load_mem (adr, 2) & ~1; /* Force alignment */
288 nia = (CTBP & ~1) + off;
289 TRACE_BRANCH3 (adr, CTBP, off);
295 rrrrr,111111,RRRRR + wwwww,00011101110:IX:::caxi
299 "caxi [reg1], reg2, reg3"
301 unsigned int z,s,cy,ov;
303 unsigned32 token,result;
307 if (mpu_load_mem_test(sd, addr, 4, reg1)
308 && mpu_store_mem_test(sd, addr, 4, reg1))
310 token = load_data_mem (sd, addr, 4);
312 TRACE_ALU_INPUT2 (token, GR[reg2]);
314 result = GR[reg2] - token;
317 s = (result & 0x80000000);
318 cy = (GR[reg2] < token);
319 ov = ((GR[reg2] & 0x80000000) != (token & 0x80000000)
320 && (GR[reg2] & 0x80000000) != (result & 0x80000000));
324 store_data_mem (sd, addr, 4, GR[reg3]);
329 store_data_mem (sd, addr, 4, token);
333 /* Set condition codes. */
334 PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
335 PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
336 | (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
338 TRACE_ALU_RESULT1 (GR[reg3]);
344 10,bbb,111110,RRRRR + dddddddddddddddd:VIII:::clr1
345 "clr1 <bit3>, <disp16>[r<reg1>]"
347 COMPAT_2 (OP_87C0 ());
350 rrrrr,111111,RRRRR + 0000000011100100:IX:::clr1
356 "clr1 r<reg2>, [r<reg1>]"
358 COMPAT_2 (OP_E407E0 ());
364 0000011111100000 + 0000000101000100:X:::ctret
373 PSW = (CTPSW & (CPU)->psw_mask);
380 rrrrr,111111,RRRRR + wwwww,011001,cccc,0:XI:::cmov
386 "cmov %s<cccc>, r<reg1>, r<reg2>, r<reg3>"
388 int cond = condition_met (cccc);
389 TRACE_ALU_INPUT3 (cond, GR[reg1], GR[reg2]);
390 GR[reg3] = cond ? GR[reg1] : GR[reg2];
391 TRACE_ALU_RESULT (GR[reg3]);
394 rrrrr,111111,iiiii + wwwww,011000,cccc,0:XII:::cmov
400 "cmov %s<cccc>, <imm5>, r<reg2>, r<reg3>"
402 int cond = condition_met (cccc);
403 TRACE_ALU_INPUT3 (cond, imm5, GR[reg2]);
404 GR[reg3] = cond ? imm5 : GR[reg2];
405 TRACE_ALU_RESULT (GR[reg3]);
411 rrrrr,001111,RRRRR:I:::cmp
412 "cmp r<reg1>, r<reg2>"
414 COMPAT_1 (OP_1E0 ());
417 rrrrr,010011,iiiii:II:::cmp
418 "cmp <imm5>, r<reg2>"
420 COMPAT_1 (OP_260 ());
426 0000011111100000 + 0000000101100000:X:::di
429 COMPAT_2 (OP_16007E0 ());
435 // 0000011001,iiiii,L + LLLLLLLLLLL,00000:XIII:::dispose
436 // "dispose <imm5>, <list12>"
437 0000011001,iiiii,L + LLLLLLLLLLL,RRRRR:XIII:::dispose
443 "dispose <imm5>, <list12>":RRRRR == 0
444 "dispose <imm5>, <list12>, [reg1]"
449 trace_input ("dispose", OP_PUSHPOP1, 0);
451 SP += (OP[3] & 0x3e) << 1;
453 /* Load the registers with lower number registers being retrieved
454 from higher addresses. */
456 if ((OP[3] & (1 << type1_regs[ i ])))
458 State.regs[ 20 + i ] = load_mem (SP, 4);
462 if ((OP[3] & 0x1f0000) != 0)
464 nia = State.regs[ (OP[3] >> 16) & 0x1f];
467 trace_output (OP_PUSHPOP1);
473 rrrrr,111111,RRRRR + wwwww,01011000000:XI:::div
479 "div r<reg1>, r<reg2>, r<reg3>"
481 COMPAT_2 (OP_2C007E0 ());
486 rrrrr!0,000010,RRRRR!0:I:::divh
487 "divh r<reg1>, r<reg2>"
490 signed long int op0, op1, result;
492 trace_input ("divh", OP_REG_REG, 0);
495 OP[0] = instruction_0 & 0x1f;
496 OP[1] = (instruction_0 >> 11) & 0x1f;
498 /* Compute the result. */
499 op0 = EXTEND16 (State.regs[OP[0]]);
500 op1 = State.regs[OP[1]];
502 if (op0 == -1 && op1 == 0x80000000)
505 PSW |= PSW_OV | PSW_S;
506 State.regs[OP[1]] = 0x80000000;
514 result = (signed32) op1 / op0;
517 /* Compute the condition codes. */
519 s = (result & 0x80000000);
521 /* Store the result and condition codes. */
522 State.regs[OP[1]] = result;
523 PSW &= ~(PSW_Z | PSW_S | PSW_OV);
524 PSW |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0) | (ov ? PSW_OV : 0));
527 trace_output (OP_REG_REG);
533 rrrrr,111111,RRRRR + wwwww,01010000000:XI:::divh
539 "divh r<reg1>, r<reg2>, r<reg3>"
541 COMPAT_2 (OP_28007E0 ());
546 rrrrr,111111,RRRRR + wwwww,01010000010:XI:::divhu
552 "divhu r<reg1>, r<reg2>, r<reg3>"
554 COMPAT_2 (OP_28207E0 ());
559 rrrrr,111111,RRRRR + wwwww,01011000010:XI:::divu
565 "divu r<reg1>, r<reg2>, r<reg3>"
567 COMPAT_2 (OP_2C207E0 ());
572 rrrrr,111111,RRRRR + wwwww,01011111100:XI:::divq
576 "divq r<reg1>, r<reg2>, r<reg3>"
578 unsigned int quotient;
579 unsigned int remainder;
580 unsigned int divide_by;
581 unsigned int divide_this;
583 TRACE_ALU_INPUT2 (GR[reg1], GR[reg2]);
585 divide_by = GR[reg1];
586 divide_this = GR[reg2];
587 v850_div (sd, divide_by, divide_this, "ient, &remainder);
589 GR[reg3] = remainder;
591 TRACE_ALU_RESULT2 (GR[reg2], GR[reg3]);
596 rrrrr,111111,RRRRR + wwwww,01011111110:XI:::divqu
600 "divq r<reg1>, r<reg2>, r<reg3>"
602 unsigned int quotient;
603 unsigned int remainder;
604 unsigned int divide_by;
605 unsigned int divide_this;
607 TRACE_ALU_INPUT2 (GR[reg1], GR[reg2]);
609 divide_by = GR[reg1];
610 divide_this = GR[reg2];
611 v850_divu (sd, divide_by, divide_this, "ient, &remainder);
613 GR[reg3] = remainder;
615 TRACE_ALU_RESULT2 (GR[reg2], GR[reg3]);
620 1000011111100000 + 0000000101100000:X:::ei
623 COMPAT_2 (OP_16087E0 ());
629 0000011111100000 + 0000000101001000:X:::eiret
635 TRACE_ALU_INPUT1 (MPM & MPM_AUE);
637 nia = EIPC; /* next PC */
644 PSW = (PSW & (PSW_NPV | PSW_DMP | PSW_IMP))
645 | (EIPSW & ~(PSW_NPV | PSW_DMP | PSW_IMP));
648 TRACE_ALU_RESULT1 (PSW);
649 TRACE_BRANCH_RESULT (nia);
655 0000011111100000 + 0000000101001010:X:::feret
661 TRACE_ALU_INPUT1 (MPM & MPM_AUE);
663 nia = FEPC; /* next PC */
670 PSW = (PSW & (PSW_NPV | PSW_DMP | PSW_IMP))
671 | (FEPSW & ~(PSW_NPV | PSW_DMP | PSW_IMP));
674 TRACE_ALU_RESULT1 (PSW);
675 TRACE_BRANCH_RESULT (nia);
680 0,bbbb!0,00001000000:I:::fetrap
691 ECR |= (0x30 + bit4) << 16;
693 PSW |= PSW_EP | PSW_ID | PSW_NP;
694 nia = 0x30; /* next PC */
696 TRACE_ALU_RESULT1 (PSW);
697 TRACE_BRANCH_RESULT (nia);
702 0000011111100000 + 0000000100100000:X:::halt
705 COMPAT_2 (OP_12007E0 ());
711 rrrrr,11111100000 + wwwww,01101000110:XII:::hsh
715 "hsh r<reg2>, r<reg3>"
718 TRACE_ALU_INPUT1 (GR[reg2]);
720 value = 0xffff & GR[reg2];
723 PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
725 if (value == 0) { PSW |= PSW_Z; PSW |= PSW_CY; }
726 if (value & 0x80000000) PSW |= PSW_S;
728 TRACE_ALU_RESULT1 (GR[reg3]);
733 rrrrr,11111100000 + wwwww,01101000100:XII:::hsw
739 "hsw r<reg2>, r<reg3>"
742 TRACE_ALU_INPUT1 (GR[reg2]);
746 value |= (GR[reg2] << 16);
750 PSW &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
752 if (value == 0) PSW |= PSW_Z;
753 if (value & 0x80000000) PSW |= PSW_S;
754 if (((value & 0xffff) == 0) || (value & 0xffff0000) == 0) PSW |= PSW_CY;
756 TRACE_ALU_RESULT (GR[reg3]);
762 rrrrr!0,11110,dddddd + ddddddddddddddd,0:V:::jarl
763 "jarl <disp22>, r<reg2>"
767 TRACE_BRANCH1 (GR[reg2]);
770 00000010111,RRRRR!0 + iiiiiiiiiiiiiiii + IIIIIIIIIIIIIIII:VI:::jarl32
774 "jarl <imm32>, r<reg1>"
777 nia = (cia + imm32) & ~1;
779 TRACE_BRANCH_RESULT (nia);
783 11000111111,RRRRR + wwwww!0,00101100000:XI:::jarl_reg
785 "jarl [r<reg1>], r<reg3>"
789 TRACE_BRANCH_RESULT (nia);
794 00000000011,RRRRR:I:::jmp
801 00000110111,RRRRR + iiiiiiiiiiiiiiii + IIIIIIIIIIIIIIII:VI:::jmp32
805 "jmp <imm32>[r<reg1>]"
807 nia = (GR[reg1] + imm32) & ~1;
809 TRACE_BRANCH_RESULT (nia);
814 0000011110,dddddd + ddddddddddddddd,0:V:::jr
823 0000001011100000 + iiiiiiiiiiiiiiii + IIIIIIIIIIIIIIII:VI:::jr32
829 nia = (cia + imm32) & ~1;
831 TRACE_BRANCH_RESULT (nia);
836 rrrrr,111000,RRRRR + dddddddddddddddd:VII:::ld.b
837 "ld.b <disp16>[r<reg1>], r<reg2>"
839 COMPAT_2 (OP_700 ());
842 00000111100,RRRRR+wwwww,ddddddd,0101+dddddddddddddddd:XIV:::ld.b
843 "ld.b <disp23>[r<reg1>], r<reg3>"
847 unsigned32 addr = GR[reg1] + disp23;
848 unsigned32 result = EXTEND8 (load_data_mem (sd, addr, 1));
850 TRACE_LD (addr, result);
853 rrrrr,111001,RRRRR + ddddddddddddddd,0:VII:::ld.h
854 "ld.h <disp16>[r<reg1>], r<reg2>"
856 COMPAT_2 (OP_720 ());
859 00000111100,RRRRR+wwwww,dddddd,00111+dddddddddddddddd:XIV:::ld.h
862 "ld.h <disp23>[r<reg1>], r<reg3>"
864 unsigned32 addr = GR[reg1] + disp23;
865 unsigned32 result = EXTEND16 (load_data_mem (sd, addr, 2));
867 TRACE_LD (addr, result);
870 rrrrr,111001,RRRRR + ddddddddddddddd,1:VII:::ld.w
871 "ld.w <disp16>[r<reg1>], r<reg2>"
873 COMPAT_2 (OP_10720 ());
876 00000111100,RRRRR+wwwww,dddddd,01001+dddddddddddddddd:XIV:::ld.w
879 "ld.w <disp23>[r<reg1>], r<reg3>"
881 unsigned32 addr = GR[reg1] + disp23;
882 unsigned32 result = load_data_mem (sd, addr, 4);
884 TRACE_LD (addr, result);
887 00000111101,RRRRR+wwwww,dddddd,01001+dddddddddddddddd:XIV:::ld.dw
889 "ld.dw <disp23>[r<reg1>], r<reg3>"
891 unsigned32 addr = GR[reg1] + disp23;
892 unsigned32 result = load_data_mem (sd, addr, 4);
894 TRACE_LD (addr, result);
895 result = load_data_mem (sd, addr + 4, 4);
896 GR[reg3 + 1] = result;
897 TRACE_LD (addr + 4, result);
900 rrrrr!0,11110,b,RRRRR + ddddddddddddddd,1:VII:::ld.bu
906 "ld.bu <disp16>[r<reg1>], r<reg2>"
908 COMPAT_2 (OP_10780 ());
911 00000111101,RRRRR+wwwww,ddddddd,0101+dddddddddddddddd:XIV:::ld.bu
914 "ld.bu <disp23>[r<reg1>], r<reg3>"
916 unsigned32 addr = GR[reg1] + disp23;
917 unsigned32 result = load_data_mem (sd, addr, 1);
919 TRACE_LD (addr, result);
922 rrrrr!0,111111,RRRRR + ddddddddddddddd,1:VII:::ld.hu
928 "ld.hu <disp16>[r<reg1>], r<reg2>"
930 COMPAT_2 (OP_107E0 ());
933 00000111101,RRRRR+wwwww,dddddd,00111+dddddddddddddddd:XIV:::ld.hu
936 "ld.hu <disp23>[r<reg1>], r<reg3>"
938 unsigned32 addr = GR[reg1] + disp23;
939 unsigned32 result = load_data_mem (sd, addr, 2);
941 TRACE_LD (addr, result);
947 regID,111111,RRRRR + selID,00000100000:IX:::ldsr
948 "ldsr r<reg1>, s<regID>":(selID == 0)
949 "ldsr r<reg1>, s<regID>, <selID>"
951 uint32 sreg = GR[reg1];
952 TRACE_ALU_INPUT1 (GR[reg1]);
954 /* FIXME: For now we ignore the selID. */
955 if (idecode_issue == idecode_v850e3v5_issue && selID != 0)
957 (CPU)->reg.selID_sregs[selID][regID] = sreg;
959 else if (( idecode_issue == idecode_v850e2_issue
960 || idecode_issue == idecode_v850e3v5_issue
961 || idecode_issue == idecode_v850e2v3_issue)
964 int protect_p = (PSW & PSW_NPV) ? 1 : 0;
966 switch (BSEL & 0xffff)
970 && ((regID >= 8 && regID <= 12)
971 || (regID >= 22 && regID <= 27)
972 || regID == PSW_REGNO))
977 case 0x1000: /* MPU0 */
979 case 0x1001: /* MPU1 */
981 case 0x2000: /* FPU */
983 && ((/* regID >= 0 && */ regID <= 5)
987 || (regID >= 11 && regID <= 26)))
999 || (regID >= 11 && regID <= 15)
1002 || (regID >= 21 && regID <= 27)))
1019 || (regID >= 21 && regID <= 27)))
1028 switch (BSEL & 0xffff)
1031 case 0xff00: /* user0 bank */
1032 case 0xffff: /* user1 bank */
1033 if(regID == PSW_REGNO)
1035 SR[regID] = sreg & ((PSW & PSW_NPV) ? 0xf : ~0);
1043 MPU0_SR[regID] = sreg;
1046 if (regID == MPC_REGNO)
1056 DCC &= ~(DCC_DCE0 | DCC_DCE1);
1060 MPU1_SR[regID] = sreg;
1063 case 0x2000: /* FPU */
1064 if (regID == FPST_REGNO)
1066 unsigned int val = FPSR & ~(FPSR_PR | FPSR_XC | FPSR_XP);
1068 val |= ((sreg & FPST_PR) ? FPSR_PR : 0)
1069 | ((sreg & FPST_XCE) ? FPSR_XCE : 0)
1070 | ((sreg & FPST_XCV) ? FPSR_XCV : 0)
1071 | ((sreg & FPST_XCZ) ? FPSR_XCZ : 0)
1072 | ((sreg & FPST_XCO) ? FPSR_XCO : 0)
1073 | ((sreg & FPST_XCU) ? FPSR_XCU : 0)
1074 | ((sreg & FPST_XCI) ? FPSR_XCI : 0)
1075 | ((sreg & FPST_XPV) ? FPSR_XPV : 0)
1076 | ((sreg & FPST_XPZ) ? FPSR_XPZ : 0)
1077 | ((sreg & FPST_XPO) ? FPSR_XPO : 0)
1078 | ((sreg & FPST_XPU) ? FPSR_XPU : 0)
1079 | ((sreg & FPST_XPI) ? FPSR_XPI : 0);
1082 else if (regID == FPCFG_REGNO)
1084 unsigned int val = FPSR & ~(FPSR_RM | FPSR_XE);
1086 val |= (((sreg & FPCFG_RM) >> 7) << 18)
1087 | ((sreg & FPCFG_XEV) ? FPSR_XEV : 0)
1088 | ((sreg & FPCFG_XEZ) ? FPSR_XEZ : 0)
1089 | ((sreg & FPCFG_XEO) ? FPSR_XEO : 0)
1090 | ((sreg & FPCFG_XEU) ? FPSR_XEU : 0)
1091 | ((sreg & FPCFG_XEI) ? FPSR_XEI : 0);
1095 FPU_SR[regID] = sreg;
1105 TRACE_ALU_RESULT (sreg);
1110 rrrrr,111111,RRRRR + wwww,0011110,mmmm,0:XI:::mac
1114 "mac r<reg1>, r<reg2>, r<reg3e>, r<reg4e>"
1119 unsigned long op2hi;
1132 op2hi = GR[reg3e+1];
1134 TRACE_ALU_INPUT4 (op0, op1, op2, op2hi);
1136 sign = (op0 ^ op1) & 0x80000000;
1138 if (((signed long) op0) < 0)
1141 if (((signed long) op1) < 0)
1144 /* We can split the 32x32 into four 16x16 operations. This ensures
1145 that we do not lose precision on 32bit only hosts: */
1146 lo = ( (op0 & 0xFFFF) * (op1 & 0xFFFF));
1147 mid1 = ( (op0 & 0xFFFF) * ((op1 >> 16) & 0xFFFF));
1148 mid2 = (((op0 >> 16) & 0xFFFF) * (op1 & 0xFFFF));
1149 hi = (((op0 >> 16) & 0xFFFF) * ((op1 >> 16) & 0xFFFF));
1151 /* We now need to add all of these results together, taking care
1152 to propogate the carries from the additions: */
1153 RdLo = Add32 (lo, (mid1 << 16), & carry);
1155 RdLo = Add32 (RdLo, (mid2 << 16), & carry);
1156 RdHi += (carry + ((mid1 >> 16) & 0xFFFF) + ((mid2 >> 16) & 0xFFFF) + hi);
1162 if (RdLo == 0xFFFFFFFF)
1171 RdLo = Add32 (RdLo, op2, & carry);
1172 RdHi += carry + op2hi;
1174 /* Store the result and condition codes. */
1176 GR[reg4e + 1 ] = RdHi;
1178 TRACE_ALU_RESULT2 (RdLo, RdHi);
1184 rrrrr,111111,RRRRR + wwww,0011111,mmmm,0:XI:::macu
1188 "macu r<reg1>, r<reg2>, r<reg3e>, r<reg4e>"
1193 unsigned long op2hi;
1205 op2hi = GR[reg3e + 1];
1207 TRACE_ALU_INPUT4 (op0, op1, op2, op2hi);
1209 /* We can split the 32x32 into four 16x16 operations. This ensures
1210 that we do not lose precision on 32bit only hosts: */
1211 lo = ( (op0 & 0xFFFF) * (op1 & 0xFFFF));
1212 mid1 = ( (op0 & 0xFFFF) * ((op1 >> 16) & 0xFFFF));
1213 mid2 = (((op0 >> 16) & 0xFFFF) * (op1 & 0xFFFF));
1214 hi = (((op0 >> 16) & 0xFFFF) * ((op1 >> 16) & 0xFFFF));
1216 /* We now need to add all of these results together, taking care
1217 to propogate the carries from the additions: */
1218 RdLo = Add32 (lo, (mid1 << 16), & carry);
1220 RdLo = Add32 (RdLo, (mid2 << 16), & carry);
1221 RdHi += (carry + ((mid1 >> 16) & 0xFFFF) + ((mid2 >> 16) & 0xFFFF) + hi);
1223 RdLo = Add32 (RdLo, op2, & carry);
1224 RdHi += carry + op2hi;
1226 /* Store the result and condition codes. */
1230 TRACE_ALU_RESULT2 (RdLo, RdHi);
1236 rrrrr!0,000000,RRRRR:I:::mov
1237 "mov r<reg1>, r<reg2>"
1239 TRACE_ALU_INPUT0 ();
1240 GR[reg2] = GR[reg1];
1241 TRACE_ALU_RESULT (GR[reg2]);
1244 rrrrr!0,010000,iiiii:II:::mov
1245 "mov <imm5>, r<reg2>"
1247 COMPAT_1 (OP_200 ());
1250 00000110001,RRRRR + iiiiiiiiiiiiiiii + IIIIIIIIIIIIIIII:VI:::mov
1256 "mov <imm32>, r<reg1>"
1259 trace_input ("mov", OP_IMM_REG, 4);
1260 State.regs[ OP[0] ] = load_mem (PC + 2, 4);
1261 trace_output (OP_IMM_REG);
1267 rrrrr!0,110001,RRRRR + iiiiiiiiiiiiiiii:VI:::movea
1268 "movea <simm16>, r<reg1>, r<reg2>"
1270 TRACE_ALU_INPUT2 (GR[reg1], simm16);
1271 GR[reg2] = GR[reg1] + simm16;
1272 TRACE_ALU_RESULT (GR[reg2]);
1278 rrrrr!0,110010,RRRRR + iiiiiiiiiiiiiiii:VI:::movhi
1279 "movhi <uimm16>, r<reg1>, r<reg2>"
1281 COMPAT_2 (OP_640 ());
1287 rrrrr,111111,RRRRR + wwwww,01000100000:XI:::mul
1293 "mul r<reg1>, r<reg2>, r<reg3>"
1295 COMPAT_2 (OP_22007E0 ());
1298 rrrrr,111111,iiiii + wwwww,01001,IIII,00:XII:::mul
1304 "mul <imm9>, r<reg2>, r<reg3>"
1306 COMPAT_2 (OP_24007E0 ());
1311 rrrrr!0,000111,RRRRR:I:::mulh
1312 "mulh r<reg1>, r<reg2>"
1314 COMPAT_1 (OP_E0 ());
1317 rrrrr!0,010111,iiiii:II:::mulh
1318 "mulh <imm5>, r<reg2>"
1320 COMPAT_1 (OP_2E0 ());
1326 rrrrr!0,110111,RRRRR + iiiiiiiiiiiiiiii:VI:::mulhi
1327 "mulhi <uimm16>, r<reg1>, r<reg2>"
1329 COMPAT_2 (OP_6E0 ());
1335 rrrrr,111111,RRRRR + wwwww,01000100010:XI:::mulu
1341 "mulu r<reg1>, r<reg2>, r<reg3>"
1343 COMPAT_2 (OP_22207E0 ());
1346 rrrrr,111111,iiiii + wwwww,01001,IIII,10:XII:::mulu
1352 "mulu <imm9>, r<reg2>, r<reg3>"
1354 COMPAT_2 (OP_24207E0 ());
1360 0000000000000000:I:::nop
1363 /* do nothing, trace nothing */
1369 rrrrr,000001,RRRRR:I:::not
1370 "not r<reg1>, r<reg2>"
1372 COMPAT_1 (OP_20 ());
1378 01,bbb,111110,RRRRR + dddddddddddddddd:VIII:::not1
1379 "not1 <bit3>, <disp16>[r<reg1>]"
1381 COMPAT_2 (OP_47C0 ());
1384 rrrrr,111111,RRRRR + 0000000011100010:IX:::not1
1390 "not1 r<reg2>, r<reg1>"
1392 COMPAT_2 (OP_E207E0 ());
1398 rrrrr,001000,RRRRR:I:::or
1399 "or r<reg1>, r<reg2>"
1401 COMPAT_1 (OP_100 ());
1407 rrrrr,110100,RRRRR + iiiiiiiiiiiiiiii:VI:::ori
1408 "ori <uimm16>, r<reg1>, r<reg2>"
1410 COMPAT_2 (OP_680 ());
1416 0000011110,iiiii,L + LLLLLLLLLLL,00001:XIII:::prepare
1422 "prepare <list12>, <imm5>"
1427 trace_input ("prepare", OP_PUSHPOP1, 0);
1429 /* Store the registers with lower number registers being placed at
1430 higher addresses. */
1431 for (i = 0; i < 12; i++)
1432 if ((OP[3] & (1 << type1_regs[ i ])))
1435 store_mem (SP, 4, State.regs[ 20 + i ]);
1438 SP -= (OP[3] & 0x3e) << 1;
1440 trace_output (OP_PUSHPOP1);
1444 0000011110,iiiii,L + LLLLLLLLLLL,00011:XIII:::prepare00
1450 "prepare <list12>, <imm5>, sp"
1452 COMPAT_2 (OP_30780 ());
1455 0000011110,iiiii,L + LLLLLLLLLLL,01011 + iiiiiiiiiiiiiiii:XIII:::prepare01
1461 "prepare <list12>, <imm5>, <uimm16>"
1463 COMPAT_2 (OP_B0780 ());
1466 0000011110,iiiii,L + LLLLLLLLLLL,10011 + iiiiiiiiiiiiiiii:XIII:::prepare10
1472 "prepare <list12>, <imm5>, <uimm16>"
1474 COMPAT_2 (OP_130780 ());
1477 0000011110,iiiii,L + LLLLLLLLLLL,11011 + iiiiiiiiiiiiiiii + dddddddddddddddd:XIII:::prepare11
1483 "prepare <list12>, <imm5>, <uimm32>"
1485 COMPAT_2 (OP_1B0780 ());
1489 0000011111100000 + 0000000101000000:X:::reti
1497 else if ((PSW & PSW_NP))
1507 TRACE_BRANCH1 (PSW);
1513 rrrrr,111111,RRRRR + 0000000010100000:IX:::sar
1514 "sar r<reg1>, r<reg2>"
1516 COMPAT_2 (OP_A007E0 ());
1519 rrrrr,010101,iiiii:II:::sar
1520 "sar <imm5>, r<reg2>"
1522 COMPAT_1 (OP_2A0 ());
1525 rrrrr,111111,RRRRR + wwwww,00010100010:XI:::sar
1529 "sar r<reg1>, r<reg2>, r<reg3>"
1531 TRACE_ALU_INPUT2 (GR[reg1], GR[reg2]);
1532 v850_sar(sd, GR[reg1], GR[reg2], &GR[reg3]);
1533 TRACE_ALU_RESULT1 (GR[reg3]);
1538 rrrrr,1111110,cccc+0000001000000000:IX:::sasf
1544 "sasf %s<cccc>, r<reg2>"
1546 COMPAT_2 (OP_20007E0 ());
1552 rrrrr!0,000110,RRRRR:I:::satadd
1553 "satadd r<reg1>, r<reg2>"
1555 COMPAT_1 (OP_C0 ());
1558 rrrrr!0,010001,iiiii:II:::satadd
1559 "satadd <imm5>, r<reg2>"
1561 COMPAT_1 (OP_220 ());
1564 rrrrr,111111,RRRRR + wwwww,01110111010:XI:::satadd
1568 "satadd r<reg1>, r<reg2>, r<reg3>"
1570 TRACE_ALU_INPUT2 (GR[reg1], GR[reg2]);
1571 v850_satadd (sd, GR[reg1], GR[reg2], &GR[reg3]);
1572 TRACE_ALU_RESULT1 (GR[reg3]);
1578 rrrrr!0,000101,RRRRR:I:::satsub
1579 "satsub r<reg1>, r<reg2>"
1581 COMPAT_1 (OP_A0 ());
1584 rrrrr,111111,RRRRR + wwwww,01110011010:XI:::satsub
1588 "satsub r<reg1>, r<reg2>, r<reg3>"
1590 TRACE_ALU_INPUT2 (GR[reg1], GR[reg2]);
1591 v850_satsub (sd, GR[reg1], GR[reg2], &GR[reg3]);
1592 TRACE_ALU_RESULT1 (GR[reg3]);
1598 rrrrr!0,110011,RRRRR + iiiiiiiiiiiiiiii:VI:::satsubi
1599 "satsubi <simm16>, r<reg1>, r<reg2>"
1601 COMPAT_2 (OP_660 ());
1607 rrrrr!0,000100,RRRRR:I:::satsubr
1608 "satsubr r<reg1>, r<reg2>"
1610 COMPAT_1 (OP_80 ());
1616 rrrrr,111111,RRRRR + wwwww,011100,cccc!13,0:XI:::sbf
1620 "sbf %s<cccc>, r<reg1>, r<reg2>, r<reg3>"
1622 int cond = condition_met (cccc);
1623 TRACE_ALU_INPUT3 (cond, GR[reg1], GR[reg2]);
1624 GR[reg3] = GR[reg2] - GR[reg1] - (cond ? 1 : 0);
1625 TRACE_ALU_RESULT1 (GR[reg3]);
1631 rrrrr,11111100000 + wwwww,01101100100:IX:::sch0l
1635 "sch0l r<reg2>, r<reg3>"
1637 unsigned int pos, op0;
1639 TRACE_ALU_INPUT1 (GR[reg2]);
1643 if (op0 == 0xffffffff)
1651 else if (op0 == 0xfffffffe)
1662 while (op0 & 0x80000000)
1675 TRACE_ALU_RESULT1 (GR[reg3]);
1681 rrrrr,11111100000 + wwwww,01101100000:IX:::sch0r
1685 "sch0r r<reg2>, r<reg3>"
1687 unsigned int pos, op0;
1689 TRACE_ALU_INPUT1 (GR[reg2]);
1693 if (op0 == 0xffffffff)
1701 else if (op0 == 0x7fffffff)
1712 while (op0 & 0x00000001)
1725 TRACE_ALU_RESULT1 (GR[reg3]);
1729 rrrrr,11111100000 + wwwww,01101100110:IX:::sch1l
1733 "sch1l r<reg2>, r<reg3>"
1735 unsigned int pos, op0;
1737 TRACE_ALU_INPUT1 (GR[reg2]);
1741 if (op0 == 0x00000000)
1749 else if (op0 == 0x00000001)
1760 while (!(op0 & 0x80000000))
1773 TRACE_ALU_RESULT1 (GR[reg3]);
1777 rrrrr,11111100000 + wwwww,01101100010:IX:::sch1r
1781 "sch1r r<reg2>, r<reg3>"
1783 unsigned int pos, op0;
1785 TRACE_ALU_INPUT1 (GR[reg2]);
1789 if (op0 == 0x00000000)
1797 else if (op0 == 0x80000000)
1808 while (!(op0 & 0x00000001))
1821 TRACE_ALU_RESULT1 (GR[reg3]);
1825 rrrrr,111111,RRRRR + wwwww,00011000010:XI:::shl
1829 "shl r<reg1>, r<reg2>, r<reg3>"
1831 TRACE_ALU_INPUT2 (GR[reg1], GR[reg2]);
1832 v850_shl(sd, GR[reg1], GR[reg2], &GR[reg3]);
1833 TRACE_ALU_RESULT1 (GR[reg3]);
1837 rrrrr,111111,RRRRR + wwwww,00010000010:XI:::shr
1841 "shr r<reg1>, r<reg2>, r<reg3>"
1843 TRACE_ALU_INPUT2 (GR[reg1], GR[reg2]);
1844 v850_shr(sd, GR[reg1], GR[reg2], &GR[reg3]);
1845 TRACE_ALU_RESULT1 (GR[reg3]);
1851 rrrrr,1111110,cccc + 0000000000000000:IX:::setf
1852 "setf %s<cccc>, r<reg2>"
1854 COMPAT_2 (OP_7E0 ());
1860 00,bbb,111110,RRRRR + dddddddddddddddd:VIII:::set1
1861 "set1 <bit3>, <disp16>[r<reg1>]"
1863 COMPAT_2 (OP_7C0 ());
1866 rrrrr,111111,RRRRR + 0000000011100000:IX:::set1
1872 "set1 r<reg2>, [r<reg1>]"
1874 COMPAT_2 (OP_E007E0 ());
1880 rrrrr,111111,RRRRR + 0000000011000000:IX:::shl
1881 "shl r<reg1>, r<reg2>"
1883 COMPAT_2 (OP_C007E0 ());
1886 rrrrr,010110,iiiii:II:::shl
1887 "shl <imm5>, r<reg2>"
1889 COMPAT_1 (OP_2C0 ());
1895 rrrrr,111111,RRRRR + 0000000010000000:IX:::shr
1896 "shr r<reg1>, r<reg2>"
1898 COMPAT_2 (OP_8007E0 ());
1901 rrrrr,010100,iiiii:II:::shr
1902 "shr <imm5>, r<reg2>"
1904 COMPAT_1 (OP_280 ());
1910 rrrrr,0110,ddddddd:IV:::sld.b
1911 "sld.bu <disp7>[ep], r<reg2>":(PSW & PSW_US)
1912 "sld.b <disp7>[ep], r<reg2>"
1914 unsigned32 addr = EP + disp7;
1915 unsigned32 result = load_mem (addr, 1);
1919 TRACE_LD_NAME ("sld.bu", addr, result);
1923 result = EXTEND8 (result);
1925 TRACE_LD (addr, result);
1929 rrrrr,1000,ddddddd:IV:::sld.h
1930 "sld.hu <disp8>[ep], r<reg2>":(PSW & PSW_US)
1931 "sld.h <disp8>[ep], r<reg2>"
1933 unsigned32 addr = EP + disp8;
1934 unsigned32 result = load_mem (addr, 2);
1938 TRACE_LD_NAME ("sld.hu", addr, result);
1942 result = EXTEND16 (result);
1944 TRACE_LD (addr, result);
1948 rrrrr,1010,dddddd,0:IV:::sld.w
1949 "sld.w <disp8>[ep], r<reg2>"
1951 unsigned32 addr = EP + disp8;
1952 unsigned32 result = load_mem (addr, 4);
1954 TRACE_LD (addr, result);
1957 rrrrr!0,0000110,dddd:IV:::sld.bu
1963 "sld.b <disp4>[ep], r<reg2>":(PSW & PSW_US)
1964 "sld.bu <disp4>[ep], r<reg2>"
1966 unsigned32 addr = EP + disp4;
1967 unsigned32 result = load_mem (addr, 1);
1970 result = EXTEND8 (result);
1972 TRACE_LD_NAME ("sld.b", addr, result);
1977 TRACE_LD (addr, result);
1981 rrrrr!0,0000111,dddd:IV:::sld.hu
1987 "sld.h <disp5>[ep], r<reg2>":(PSW & PSW_US)
1988 "sld.hu <disp5>[ep], r<reg2>"
1990 unsigned32 addr = EP + disp5;
1991 unsigned32 result = load_mem (addr, 2);
1994 result = EXTEND16 (result);
1996 TRACE_LD_NAME ("sld.h", addr, result);
2001 TRACE_LD (addr, result);
2008 rrrrr,0111,ddddddd:IV:::sst.b
2009 "sst.b r<reg2>, <disp7>[ep]"
2011 COMPAT_1 (OP_380 ());
2014 rrrrr,1001,ddddddd:IV:::sst.h
2015 "sst.h r<reg2>, <disp8>[ep]"
2017 COMPAT_1 (OP_480 ());
2020 rrrrr,1010,dddddd,1:IV:::sst.w
2021 "sst.w r<reg2>, <disp8>[ep]"
2023 COMPAT_1 (OP_501 ());
2027 rrrrr,111010,RRRRR + dddddddddddddddd:VII:::st.b
2028 "st.b r<reg2>, <disp16>[r<reg1>]"
2030 COMPAT_2 (OP_740 ());
2033 00000111100,RRRRR + wwwww,ddddddd,1101 + dddddddddddddddd:XIV:::st.b
2036 "st.b r<reg3>, <disp23>[r<reg1>]"
2038 unsigned32 addr = GR[reg1] + disp23;
2039 store_data_mem (sd, addr, 1, GR[reg3]);
2040 TRACE_ST (addr, GR[reg3]);
2043 rrrrr,111011,RRRRR + ddddddddddddddd,0:VII:::st.h
2044 "st.h r<reg2>, <disp16>[r<reg1>]"
2046 COMPAT_2 (OP_760 ());
2049 00000111101,RRRRR+wwwww,dddddd,01101+dddddddddddddddd:XIV:::st.h
2052 "st.h r<reg3>, <disp23>[r<reg1>]"
2054 unsigned32 addr = GR[reg1] + disp23;
2055 store_data_mem (sd, addr, 2, GR[reg3]);
2056 TRACE_ST (addr, GR[reg3]);
2059 rrrrr,111011,RRRRR + ddddddddddddddd,1:VII:::st.w
2060 "st.w r<reg2>, <disp16>[r<reg1>]"
2062 COMPAT_2 (OP_10760 ());
2065 00000111100,RRRRR+wwwww,dddddd,01111+dddddddddddddddd:XIV:::st.w
2068 "st.w r<reg3>, <disp23>[r<reg1>]"
2070 unsigned32 addr = GR[reg1] + disp23;
2071 store_data_mem (sd, addr, 4, GR[reg3]);
2072 TRACE_ST (addr, GR[reg3]);
2075 00000111101,RRRRR+wwwww,dddddd,01111+dddddddddddddddd:XIV:::st.dw
2077 "st.dw r<reg3>, <disp23>[r<reg1>]"
2079 unsigned32 addr = GR[reg1] + disp23;
2080 store_data_mem (sd, addr, 4, GR[reg3]);
2081 TRACE_ST (addr, GR[reg3]);
2082 store_data_mem (sd, addr + 4, 4, GR[reg3 + 1]);
2083 TRACE_ST (addr + 4, GR[reg3 + 1]);
2088 rrrrr,111111,regID + 0000000001000000:IX:::stsr
2089 "stsr s<regID>, r<reg2>"
2093 if ((idecode_issue == idecode_v850e2_issue
2094 || idecode_issue == idecode_v850e3v5_issue
2095 || idecode_issue == idecode_v850e2v3_issue)
2098 switch (BSEL & 0xffff)
2101 case 0xff00: /* USER 0 */
2102 case 0xffff: /* USER 1 */
2106 sreg = MPU0_SR[regID];
2109 sreg = MPU1_SR[regID];
2112 if (regID == FPST_REGNO)
2114 sreg = ((FPSR & FPSR_PR) ? FPST_PR : 0)
2115 | ((FPSR & FPSR_XCE) ? FPST_XCE : 0)
2116 | ((FPSR & FPSR_XCV) ? FPST_XCV : 0)
2117 | ((FPSR & FPSR_XCZ) ? FPST_XCZ : 0)
2118 | ((FPSR & FPSR_XCO) ? FPST_XCO : 0)
2119 | ((FPSR & FPSR_XCU) ? FPST_XCU : 0)
2120 | ((FPSR & FPSR_XCI) ? FPST_XCI : 0)
2121 | ((FPSR & FPSR_XPV) ? FPST_XPV : 0)
2122 | ((FPSR & FPSR_XPZ) ? FPST_XPZ : 0)
2123 | ((FPSR & FPSR_XPO) ? FPST_XPO : 0)
2124 | ((FPSR & FPSR_XPU) ? FPST_XPU : 0)
2125 | ((FPSR & FPSR_XPI) ? FPST_XPI : 0);
2127 else if (regID == FPCFG_REGNO)
2129 sreg = (((FPSR & FPSR_RM) >> 18) << 7)
2130 | ((FPSR & FPSR_XEV) ? FPCFG_XEV : 0)
2131 | ((FPSR & FPSR_XEZ) ? FPCFG_XEZ : 0)
2132 | ((FPSR & FPSR_XEO) ? FPCFG_XEO : 0)
2133 | ((FPSR & FPSR_XEU) ? FPCFG_XEU : 0)
2134 | ((FPSR & FPSR_XEI) ? FPCFG_XEI : 0);
2138 sreg = FPU_SR[regID];
2148 TRACE_ALU_INPUT1 (sreg);
2150 TRACE_ALU_RESULT (GR[reg2]);
2154 rrrrr,001101,RRRRR:I:::sub
2155 "sub r<reg1>, r<reg2>"
2157 COMPAT_1 (OP_1A0 ());
2161 rrrrr,001100,RRRRR:I:::subr
2162 "subr r<reg1>, r<reg2>"
2164 COMPAT_1 (OP_180 ());
2168 00000000010,RRRRR:I:::switch
2178 trace_input ("switch", OP_REG, 0);
2179 adr = (cia + 2) + (State.regs[ reg1 ] << 1);
2180 nia = (cia + 2) + (EXTEND16 (load_mem (adr, 2)) << 1);
2181 trace_output (OP_REG);
2185 00000000101,RRRRR:I:::sxb
2193 TRACE_ALU_INPUT1 (GR[reg1]);
2194 GR[reg1] = EXTEND8 (GR[reg1]);
2195 TRACE_ALU_RESULT (GR[reg1]);
2199 00000000111,RRRRR:I:::sxh
2207 TRACE_ALU_INPUT1 (GR[reg1]);
2208 GR[reg1] = EXTEND16 (GR[reg1]);
2209 TRACE_ALU_RESULT (GR[reg1]);
2213 00000111111,iiiii + 0000000100000000:X:::trap
2216 COMPAT_2 (OP_10007E0 ());
2220 rrrrr,001011,RRRRR:I:::tst
2221 "tst r<reg1>, r<reg2>"
2223 COMPAT_1 (OP_160 ());
2227 11,bbb,111110,RRRRR + dddddddddddddddd:VIII:::tst1
2228 "tst1 <bit3>, <disp16>[r<reg1>]"
2230 COMPAT_2 (OP_C7C0 ());
2233 rrrrr,111111,RRRRR + 0000000011100110:IX:::tst1
2239 "tst1 r<reg2>, [r<reg1>]"
2241 COMPAT_2 (OP_E607E0 ());
2245 rrrrr,001001,RRRRR:I:::xor
2246 "xor r<reg1>, r<reg2>"
2248 COMPAT_1 (OP_120 ());
2252 rrrrr,110101,RRRRR + iiiiiiiiiiiiiiii:VI:::xori
2253 "xori <uimm16>, r<reg1>, r<reg2>"
2255 COMPAT_2 (OP_6A0 ());
2259 00000000100,RRRRR:I:::zxb
2267 TRACE_ALU_INPUT1 (GR[reg1]);
2268 GR[reg1] = GR[reg1] & 0xff;
2269 TRACE_ALU_RESULT (GR[reg1]);
2273 00000000110,RRRRR:I:::zxh
2281 TRACE_ALU_INPUT1 (GR[reg1]);
2282 GR[reg1] = GR[reg1] & 0xffff;
2283 TRACE_ALU_RESULT (GR[reg1]);
2286 // Right field must be zero so that it doesn't clash with DIVH
2287 // Left field must be non-zero so that it doesn't clash with SWITCH
2288 11111,000010,00000:I:::break
2292 sim_engine_halt (SD, CPU, NULL, cia, sim_stopped, SIM_SIGTRAP);
2295 11111,000010,00000:I:::dbtrap
2302 if (STATE_OPEN_KIND (SD) == SIM_OPEN_DEBUG)
2304 sim_engine_halt (SD, CPU, NULL, cia, sim_stopped, SIM_SIGTRAP);
2310 PSW = PSW | (PSW_NP | PSW_EP | PSW_ID);
2317 // New breakpoint: 0x7E0 0x7E0
2318 00000,111111,00000 + 00000,11111,100000:X:::ilgop
2320 sim_engine_halt (SD, CPU, NULL, cia, sim_stopped, SIM_SIGTRAP);
2323 // Return from debug trap: 0x146007e0
2324 0000011111100000 + 0000000101000110:X:::dbret
2333 TRACE_BRANCH1 (PSW);
2341 // Map condition code to a string
2342 :%s::::FFFF:int FFFF
2347 case 1: return "un";
2348 case 2: return "eq";
2349 case 3: return "ueq";
2350 case 4: return "olt";
2351 case 5: return "ult";
2352 case 6: return "ole";
2353 case 7: return "ule";
2354 case 8: return "sf";
2355 case 9: return "ngle";
2356 case 10: return "seq";
2357 case 11: return "ngl";
2358 case 12: return "lt";
2359 case 13: return "nge";
2360 case 14: return "le";
2361 case 15: return "ngt";
2367 rrrr,011111100000 + wwww,010001011000:F_I:::absf_d
2370 "absf.d r<reg2e>, r<reg3e>"
2373 sim_fpu_status status;
2375 sim_fpu_232to (&wop, GR[reg2e+1], GR[reg2e]);
2376 TRACE_FP_INPUT_FPU1 (&wop);
2378 status = sim_fpu_abs (&ans, &wop);
2379 check_invalid_snan(sd, status, 1);
2381 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &ans);
2383 TRACE_FP_RESULT_FPU1 (&ans);
2387 rrrrr,11111100000 + wwwww,10001001000:F_I:::absf_s
2390 "absf.s r<reg2>, r<reg3>"
2393 sim_fpu_status status;
2395 sim_fpu_32to (&wop, GR[reg2]);
2396 TRACE_FP_INPUT_FPU1 (&wop);
2398 status = sim_fpu_abs (&ans, &wop);
2399 check_invalid_snan(sd, status, 0);
2401 sim_fpu_to32 (&GR[reg3], &ans);
2402 TRACE_FP_RESULT_FPU1 (&ans);
2406 rrrr,0111111,RRRR,0 + wwww,010001110000:F_I:::addf_d
2409 "addf.d r<reg1e>, r<reg2e>, r<reg3e>"
2411 sim_fpu ans, wop1, wop2;
2412 sim_fpu_status status;
2414 sim_fpu_232to (&wop1, GR[reg1e+1], GR[reg1e]);
2415 sim_fpu_232to (&wop2, GR[reg2e+1], GR[reg2e]);
2416 TRACE_FP_INPUT_FPU2 (&wop1, &wop2);
2418 status = sim_fpu_add (&ans, &wop1, &wop2);
2419 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
2421 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 1);
2423 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &ans);
2424 TRACE_FP_RESULT_FPU1 (&ans);
2428 rrrrr,111111,RRRRR + wwwww,10001100000:F_I:::addf_s
2431 "addf.s r<reg1>, r<reg2>, r<reg3>"
2433 sim_fpu ans, wop1, wop2;
2434 sim_fpu_status status;
2436 sim_fpu_32to (&wop1, GR[reg1]);
2437 sim_fpu_32to (&wop2, GR[reg2]);
2438 TRACE_FP_INPUT_FPU2 (&wop1, &wop2);
2440 status = sim_fpu_add (&ans, &wop1, &wop2);
2441 status |= sim_fpu_round_32 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
2443 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
2445 sim_fpu_to32 (&GR[reg3], &ans);
2446 TRACE_FP_RESULT_FPU1 (&ans);
2450 rrrr,0111111,RRRR,0 + wwww!0,01000001,bbb,0:F_I:::cmovf_d
2453 "cmovf.d <bbb>, r<reg1e>, r<reg2e>, r<reg3e>"
2455 unsigned int ophi,oplow;
2456 sim_fpu ans, wop1, wop2;
2458 sim_fpu_232to (&wop1, GR[reg1e+1], GR[reg1e]);
2459 sim_fpu_232to (&wop2, GR[reg2e+1], GR[reg2e]);
2460 TRACE_FP_INPUT_BOOL1_FPU2 (TEST_FPCC(bbb), &wop1, &wop2);
2477 TRACE_FP_RESULT_FPU1 (&ans);;
2481 rrrrr,111111,RRRRR!0 + wwwww!0,1000000,bbb,0:F_I:::cmovf_s
2484 "cmovf.d <bbb>, r<reg1>, r<reg2>, r<reg3>"
2487 sim_fpu ans, wop1, wop2;
2489 sim_fpu_32to (&wop1, GR[reg1]);
2490 sim_fpu_32to (&wop2, GR[reg2]);
2491 TRACE_FP_INPUT_BOOL1_FPU2 (TEST_FPCC(bbb), &wop1, &wop2);
2505 TRACE_FP_RESULT_FPU1 (&ans);
2509 rrrr,0111111,RRRR,0 + 0,FFFF,1000011,bbb,0:F_I:::cmpf_d
2512 "cmpf.d %s<FFFF>, r<reg2e>, r<reg1e>":(bbb == 0)
2513 "cmpf.d %s<FFFF>, r<reg2e>, r<reg1e>, <bbb>"
2519 sim_fpu_232to (&wop1, GR[reg1e+1], GR[reg1e]);
2520 sim_fpu_232to (&wop2, GR[reg2e+1], GR[reg2e]);
2521 TRACE_FP_INPUT_FPU2 (&wop2, &wop1);
2523 result = v850_float_compare(sd, FFFF, wop2, wop1, 1);
2530 TRACE_FP_RESULT_BOOL (result);
2534 rrrrr,111111,RRRRR + 0,FFFF,1000010,bbb,0:F_I:::cmpf_s
2537 "cmpf.s %s<FFFF>, r<reg2>, r<reg1>":(bbb == 0)
2538 "cmpf.s %s<FFFF>, r<reg2>, r<reg1>, <bbb>"
2544 sim_fpu_32to( &wop1, GR[reg1] );
2545 sim_fpu_32to( &wop2, GR[reg2] );
2546 TRACE_FP_INPUT_FPU2 (&wop2, &wop1);
2548 result = v850_float_compare(sd, FFFF, wop2, wop1, 0);
2555 TRACE_FP_RESULT_BOOL (result);
2559 rrrr,011111100100 + wwww,010001010100:F_I:::cvtf_dl
2562 "cvtf.dl r<reg2e>, r<reg3e>"
2566 sim_fpu_status status;
2568 sim_fpu_232to (&wop, GR[reg2e+1], GR[reg2e]);
2569 TRACE_FP_INPUT_FPU1 (&wop);
2571 status = sim_fpu_round_64 (&wop, FPSR_GET_ROUND(), sim_fpu_denorm_zero);
2572 status |= sim_fpu_to64i (&ans, &wop, FPSR_GET_ROUND());
2574 check_cvt_fi(sd, status, 1);
2577 GR[reg3e+1] = ans>>32L;
2578 TRACE_FP_RESULT_WORD2 (GR[reg3e], GR[reg3e+1]);
2582 rrrr,011111100011 + wwwww,10001010010:F_I:::cvtf_ds
2585 "cvtf.ds r<reg2e>, r<reg3>"
2588 sim_fpu_status status;
2590 sim_fpu_232to (&wop, GR[reg2e+1], GR[reg2e]);
2591 TRACE_FP_INPUT_FPU1 (&wop);
2593 status = sim_fpu_round_32 (&wop, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
2595 check_cvt_fi(sd, status, 0);
2597 sim_fpu_to32 (&GR[reg3], &wop);
2598 TRACE_FP_RESULT_FPU1 (&wop);
2602 rrrr,011111100100 + wwwww,10001010000:F_I:::cvtf_dw
2605 "cvtf.dw r<reg2e>, r<reg3>"
2609 sim_fpu_status status;
2611 sim_fpu_232to (&wop, GR[reg2e+1], GR[reg2e]);
2612 TRACE_FP_INPUT_FPU1 (&wop);
2614 status = sim_fpu_round_32 (&wop, FPSR_GET_ROUND(), sim_fpu_denorm_zero);
2615 status |= sim_fpu_to32i (&ans, &wop, FPSR_GET_ROUND());
2617 check_cvt_fi(sd, status, 1);
2620 TRACE_FP_RESULT_WORD1 (ans);
2624 rrrr,011111100001 + wwww,010001010010:F_I:::cvtf_ld
2627 "cvtf.ld r<reg2e>, r<reg3e>"
2631 sim_fpu_status status;
2633 op = ((signed64)GR[reg2e+1] << 32L) | GR[reg2e];
2634 TRACE_FP_INPUT_WORD2 (GR[reg2e], GR[reg2e+1]);
2636 sim_fpu_i64to (&wop, op, FPSR_GET_ROUND());
2637 status = sim_fpu_round_64 (&wop, FPSR_GET_ROUND(), sim_fpu_denorm_zero);
2639 check_cvt_if(sd, status, 1);
2641 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &wop);
2642 TRACE_FP_RESULT_FPU1 (&wop);
2646 rrrr,011111100001 + wwwww,10001000010:F_I:::cvtf_ls
2649 "cvtf.ls r<reg2e>, r<reg3>"
2653 sim_fpu_status status;
2655 op = ((signed64)GR[reg2e+1] << 32L) | GR[reg2e];
2656 TRACE_FP_INPUT_WORD2 (GR[reg2e], GR[reg2e+1]);
2658 sim_fpu_i64to (&wop, op, FPSR_GET_ROUND());
2659 status = sim_fpu_round_32 (&wop, FPSR_GET_ROUND(), sim_fpu_denorm_zero);
2661 check_cvt_if(sd, status, 0);
2663 sim_fpu_to32 (&GR[reg3], &wop);
2664 TRACE_FP_RESULT_FPU1 (&wop);
2668 rrrrr,11111100010 + wwww,010001010010:F_I:::cvtf_sd
2671 "cvtf.sd r<reg2>, r<reg3e>"
2674 sim_fpu_status status;
2676 sim_fpu_32to (&wop, GR[reg2]);
2677 TRACE_FP_INPUT_FPU1 (&wop);
2678 status = sim_fpu_round_64 (&wop, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
2680 check_cvt_ff(sd, status, 1);
2682 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &wop);
2683 TRACE_FP_RESULT_FPU1 (&wop);
2687 rrrrr,11111100100 + wwww,010001000100:F_I:::cvtf_sl
2690 "cvtf.sl r<reg2>, r<reg3e>"
2694 sim_fpu_status status;
2696 sim_fpu_32to (&wop, GR[reg2]);
2697 TRACE_FP_INPUT_FPU1 (&wop);
2699 status = sim_fpu_round_64 (&wop, FPSR_GET_ROUND(), sim_fpu_denorm_zero);
2700 status |= sim_fpu_to64i (&ans, &wop, FPSR_GET_ROUND());
2702 check_cvt_fi(sd, status, 0);
2705 GR[reg3e+1] = ans >> 32L;
2706 TRACE_FP_RESULT_WORD2 (GR[reg3e], GR[reg3e+1]);
2710 rrrrr,11111100100 + wwwww,10001000000:F_I:::cvtf_sw
2713 "cvtf.sw r<reg2>, r<reg3>"
2717 sim_fpu_status status;
2719 sim_fpu_32to (&wop, GR[reg2]);
2720 TRACE_FP_INPUT_FPU1 (&wop);
2722 status = sim_fpu_round_32 (&wop, FPSR_GET_ROUND(), sim_fpu_denorm_zero);
2723 status |= sim_fpu_to32i (&ans, &wop, sim_fpu_round_zero);
2725 check_cvt_fi(sd, status, 0);
2728 TRACE_FP_RESULT_WORD1 (ans);
2732 rrrrr,11111100000 + wwww,010001010010:F_I:::cvtf_wd
2735 "cvtf.wd r<reg2>, r<reg3e>"
2738 sim_fpu_status status;
2740 TRACE_FP_INPUT_WORD1 (GR[reg2]);
2741 sim_fpu_i32to (&wop, GR[reg2], FPSR_GET_ROUND());
2742 status = sim_fpu_round_64 (&wop, FPSR_GET_ROUND(), sim_fpu_denorm_zero);
2744 check_cvt_if(sd, status, 1);
2746 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &wop);
2747 TRACE_FP_RESULT_FPU1 (&wop);
2751 rrrrr,11111100000 + wwwww,10001000010:F_I:::cvtf_ws
2754 "cvtf.ws r<reg2>, r<reg3>"
2757 sim_fpu_status status;
2759 TRACE_FP_INPUT_WORD1 (GR[reg2]);
2760 sim_fpu_i32to (&wop, GR[reg2], FPSR_GET_ROUND());
2761 status = sim_fpu_round_32 (&wop, FPSR_GET_ROUND(), sim_fpu_denorm_zero);
2763 check_cvt_if(sd, status, 0);
2765 sim_fpu_to32 (&GR[reg3], &wop);
2766 TRACE_FP_RESULT_FPU1 (&wop);
2770 rrrr,0111111,RRRR,0 + wwww,010001111110:F_I:::divf_d
2773 "divf.d r<reg1e>, r<reg2e>, r<reg3e>"
2775 sim_fpu ans, wop1, wop2;
2776 sim_fpu_status status;
2778 sim_fpu_232to (&wop1, GR[reg1e+1], GR[reg1e]);
2779 sim_fpu_232to (&wop2, GR[reg2e+1], GR[reg2e]);
2780 TRACE_FP_INPUT_FPU2 (&wop1, &wop2);
2782 status = sim_fpu_div (&ans, &wop2, &wop1);
2783 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
2785 update_fpsr (sd, status, FPSR_XEV | FPSR_XEZ | FPSR_XEI | FPSR_XEO | FPSR_XEU, 1);
2787 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &ans);
2788 TRACE_FP_RESULT_FPU1 (&ans);
2792 rrrrr,111111,RRRRR + wwwww,10001101110:F_I:::divf_s
2795 "divf.s r<reg1>, r<reg2>, r<reg3>"
2797 sim_fpu ans, wop1, wop2;
2798 sim_fpu_status status;
2800 sim_fpu_32to (&wop1, GR[reg1]);
2801 sim_fpu_32to (&wop2, GR[reg2]);
2802 TRACE_FP_INPUT_FPU2 (&wop1, &wop2);
2804 status = sim_fpu_div (&ans, &wop2, &wop1);
2805 status |= sim_fpu_round_32 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
2807 update_fpsr (sd, status, FPSR_XEV | FPSR_XEZ | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
2809 sim_fpu_to32 (&GR[reg3], &ans);
2810 TRACE_FP_RESULT_FPU1 (&ans);
2814 rrrrr,111111,RRRRR + wwwww,101,W,00,WWWW,0:F_I:::maddf_s
2816 "maddf.s r<reg1>, r<reg2>, r<reg3>, r<reg4>"
2818 sim_fpu ans, wop1, wop2, wop3;
2819 sim_fpu_status status;
2821 sim_fpu_32to (&wop1, GR[reg1]);
2822 sim_fpu_32to (&wop2, GR[reg2]);
2823 sim_fpu_32to (&wop3, GR[reg3]);
2824 TRACE_FP_INPUT_FPU3 (&wop1, &wop2, &wop3);
2826 status = sim_fpu_mul (&ans, &wop1, &wop2);
2828 status |= sim_fpu_add (&ans, &wop1, &wop3);
2829 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
2831 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
2833 sim_fpu_to32 (&GR[reg4], &ans);
2834 TRACE_FP_RESULT_FPU1 (&ans);
2838 rrrrr,111111,RRRRR + wwwww,10011100000:F_I:::fmaf_s
2840 "fmaf.s r<reg1>, r<reg2>, r<reg3>"
2842 sim_fpu ans, wop1, wop2, wop3;
2843 sim_fpu_status status;
2845 sim_fpu_32to (&wop1, GR[reg1]);
2846 sim_fpu_32to (&wop2, GR[reg2]);
2847 sim_fpu_32to (&wop3, GR[reg3]);
2848 TRACE_FP_INPUT_FPU3 (&wop1, &wop2, &wop3);
2850 status = sim_fpu_mul (&ans, &wop1, &wop2);
2852 status |= sim_fpu_add (&ans, &wop1, &wop3);
2853 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
2855 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
2857 sim_fpu_to32 (&GR[reg3], &ans);
2858 TRACE_FP_RESULT_FPU1 (&ans);
2862 rrrr,0111111,RRRR,0 + wwww,010001111000:F_I:::maxf_d
2865 "maxf.d r<reg1e>, r<reg2e>, r<reg3e>"
2867 sim_fpu ans, wop1, wop2;
2869 sim_fpu_232to (&wop1, GR[reg1e+1], GR[reg1e]);
2870 sim_fpu_232to (&wop2, GR[reg2e+1], GR[reg2e]);
2871 TRACE_FP_INPUT_FPU2 (&wop1, &wop2);
2873 if (sim_fpu_is_nan(&wop1) || sim_fpu_is_nan(&wop2))
2875 if (FPSR & FPSR_XEV)
2877 SignalExceptionFPE(sd, 1);
2884 else if (FPSR & FPSR_FS
2885 && ((sim_fpu_is_zero (&wop1) || sim_fpu_is_denorm (&wop1))
2886 && (sim_fpu_is_zero (&wop2) || sim_fpu_is_denorm (&wop2))))
2892 sim_fpu_max (&ans, &wop1, &wop2);
2895 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &ans);
2896 TRACE_FP_RESULT_FPU1 (&ans);
2900 rrrrr,111111,RRRRR + wwwww,10001101000:F_I:::maxf_s
2903 "maxf.s r<reg1>, r<reg2>, r<reg3>"
2905 sim_fpu ans, wop1, wop2;
2907 sim_fpu_32to (&wop1, GR[reg1]);
2908 sim_fpu_32to (&wop2, GR[reg2]);
2909 TRACE_FP_INPUT_FPU2 (&wop1, &wop2);
2911 if (sim_fpu_is_nan(&wop1) || sim_fpu_is_nan(&wop2))
2913 if (FPSR & FPSR_XEV)
2915 SignalExceptionFPE(sd, 0);
2922 else if ((FPSR & FPSR_FS)
2923 && ((sim_fpu_is_zero (&wop1) || sim_fpu_is_denorm (&wop1))
2924 && (sim_fpu_is_zero (&wop2)|| sim_fpu_is_denorm (&wop2))))
2930 sim_fpu_max (&ans, &wop1, &wop2);
2933 sim_fpu_to32 (&GR[reg3], &ans);
2934 TRACE_FP_RESULT_FPU1 (&ans);
2938 rrrr,0111111,RRRR,0 + wwww,010001111010:F_I:::minf_d
2941 "minf.d r<reg1e>, r<reg2e>, r<reg3e>"
2943 sim_fpu ans, wop1, wop2;
2945 sim_fpu_232to (&wop1, GR[reg1e+1], GR[reg1e]);
2946 sim_fpu_232to (&wop2, GR[reg2e+1], GR[reg2e]);
2947 TRACE_FP_INPUT_FPU2 (&wop1, &wop2);
2949 if (sim_fpu_is_nan(&wop1) || sim_fpu_is_nan(&wop2))
2951 if (FPSR & FPSR_XEV)
2953 SignalExceptionFPE(sd, 1);
2960 else if (FPSR & FPSR_FS
2961 && ((sim_fpu_is_zero (&wop1) || sim_fpu_is_denorm (&wop1))
2962 && (sim_fpu_is_zero (&wop2) || sim_fpu_is_denorm (&wop2))))
2968 sim_fpu_min (&ans, &wop1, &wop2);
2971 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &ans);
2972 TRACE_FP_RESULT_FPU1 (&ans);
2976 rrrrr,111111,RRRRR + wwwww,10001101010:F_I:::minf_s
2979 "minf.s r<reg1>, r<reg2>, r<reg3>"
2981 sim_fpu ans, wop1, wop2;
2983 sim_fpu_32to (&wop1, GR[reg1]);
2984 sim_fpu_32to (&wop2, GR[reg2]);
2985 TRACE_FP_INPUT_FPU2 (&wop1, &wop2);
2987 if (sim_fpu_is_nan(&wop1) || sim_fpu_is_nan(&wop2))
2989 if (FPSR & FPSR_XEV)
2991 SignalExceptionFPE(sd, 0);
2998 else if (FPSR & FPSR_FS
2999 && ((sim_fpu_is_zero (&wop1) || sim_fpu_is_denorm (&wop1))
3000 && (sim_fpu_is_zero (&wop2) || sim_fpu_is_denorm (&wop2))))
3006 sim_fpu_min (&ans, &wop1, &wop2);
3009 sim_fpu_to32 (&GR[reg3], &ans);
3010 TRACE_FP_RESULT_FPU1 (&ans);
3014 rrrrr,111111,RRRRR + wwwww,101,W,01,WWWW,0:F_I:::msubf_s
3016 "msubf.s r<reg1>, r<reg2>, r<reg3>, r<reg4>"
3018 sim_fpu ans, wop1, wop2, wop3;
3019 sim_fpu_status status;
3021 sim_fpu_32to (&wop1, GR[reg1]);
3022 sim_fpu_32to (&wop2, GR[reg2]);
3023 sim_fpu_32to (&wop3, GR[reg3]);
3024 TRACE_FP_INPUT_FPU3 (&wop1, &wop2, &wop3);
3026 status = sim_fpu_mul (&ans, &wop1, &wop2);
3027 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3029 status |= sim_fpu_sub (&ans, &wop1, &wop3);
3030 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3032 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
3034 sim_fpu_to32 (&GR[reg4], &ans);
3035 TRACE_FP_RESULT_FPU1 (&ans);
3039 rrrrr,111111,RRRRR + wwwww,10011100010:F_I:::fmsf_s
3041 "fmsf.s r<reg1>, r<reg2>, r<reg3>"
3043 sim_fpu ans, wop1, wop2, wop3;
3044 sim_fpu_status status;
3046 sim_fpu_32to (&wop1, GR[reg1]);
3047 sim_fpu_32to (&wop2, GR[reg2]);
3048 sim_fpu_32to (&wop3, GR[reg3]);
3049 TRACE_FP_INPUT_FPU3 (&wop1, &wop2, &wop3);
3051 status = sim_fpu_mul (&ans, &wop1, &wop2);
3052 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3054 status |= sim_fpu_sub (&ans, &wop1, &wop3);
3055 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3057 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
3059 sim_fpu_to32 (&GR[reg3], &ans);
3060 TRACE_FP_RESULT_FPU1 (&ans);
3064 rrrr,0111111,RRRR,0 + wwww,010001110100:F_I:::mulf_d
3067 "mulf.d r<reg1e>, r<reg2e>, r<reg3e>"
3069 sim_fpu ans, wop1, wop2;
3070 sim_fpu_status status;
3072 sim_fpu_232to (&wop1, GR[reg1e+1], GR[reg1e]);
3073 sim_fpu_232to (&wop2, GR[reg2e+1], GR[reg2e]);
3074 TRACE_FP_INPUT_FPU2 (&wop1, &wop2);
3076 status = sim_fpu_mul (&ans, &wop1, &wop2);
3077 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3079 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 1);
3081 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &ans);
3082 TRACE_FP_RESULT_FPU1 (&ans);
3086 rrrrr,111111,RRRRR + wwwww,10001100100:F_I:::mulf_s
3089 "mulf.s r<reg1>, r<reg2>, r<reg3>"
3091 sim_fpu ans, wop1, wop2;
3092 sim_fpu_status status;
3094 sim_fpu_32to (&wop1, GR[reg1]);
3095 sim_fpu_32to (&wop2, GR[reg2]);
3096 TRACE_FP_INPUT_FPU2 (&wop1, &wop2);
3098 status = sim_fpu_mul (&ans, &wop1, &wop2);
3099 status |= sim_fpu_round_32 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3101 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
3103 sim_fpu_to32 (&GR[reg3], &ans);
3104 TRACE_FP_RESULT_FPU1 (&ans);
3108 rrrr,011111100001 + wwww,010001011000:F_I:::negf_d
3111 "negf.d r<reg2e>, r<reg3e>"
3114 sim_fpu_status status;
3116 sim_fpu_232to (&wop, GR[reg2e+1], GR[reg2e]);
3117 TRACE_FP_INPUT_FPU1 (&wop);
3119 status = sim_fpu_neg (&ans, &wop);
3121 check_invalid_snan(sd, status, 1);
3123 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &ans);
3124 TRACE_FP_RESULT_FPU1 (&ans);
3128 rrrrr,11111100001 + wwwww,10001001000:F_I:::negf_s
3131 "negf.s r<reg2>, r<reg3>"
3134 sim_fpu_status status;
3136 sim_fpu_32to (&wop, GR[reg2]);
3137 TRACE_FP_INPUT_FPU1 (&wop);
3139 status = sim_fpu_neg (&ans, &wop);
3141 check_invalid_snan(sd, status, 0);
3143 sim_fpu_to32 (&GR[reg3], &ans);
3144 TRACE_FP_RESULT_FPU1 (&ans);
3148 rrrrr,111111,RRRRR + wwwww,101,W,10,WWWW,0:F_I:::nmaddf_s
3150 "nmaddf.s r<reg1>, r<reg2>, r<reg3>, r<reg4>"
3152 sim_fpu ans, wop1, wop2, wop3;
3153 sim_fpu_status status;
3155 sim_fpu_32to (&wop1, GR[reg1]);
3156 sim_fpu_32to (&wop2, GR[reg2]);
3157 sim_fpu_32to (&wop3, GR[reg3]);
3158 TRACE_FP_INPUT_FPU3 (&wop1, &wop2, &wop3);
3160 status = sim_fpu_mul (&ans, &wop1, &wop2);
3162 status |= sim_fpu_add (&ans, &wop1, &wop3);
3163 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3165 status |= sim_fpu_neg (&ans, &wop1);
3167 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
3169 sim_fpu_to32 (&GR[reg4], &ans);
3170 TRACE_FP_RESULT_FPU1 (&ans);
3174 rrrrr,111111,RRRRR + wwwww,10011100100:F_I:::fnmaf_s
3176 "fnmaf.s r<reg1>, r<reg2>, r<reg3>"
3178 sim_fpu ans, wop1, wop2, wop3;
3179 sim_fpu_status status;
3181 sim_fpu_32to (&wop1, GR[reg1]);
3182 sim_fpu_32to (&wop2, GR[reg2]);
3183 sim_fpu_32to (&wop3, GR[reg3]);
3184 TRACE_FP_INPUT_FPU3 (&wop1, &wop2, &wop3);
3186 status = sim_fpu_mul (&ans, &wop1, &wop2);
3188 status |= sim_fpu_add (&ans, &wop1, &wop3);
3189 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3191 status |= sim_fpu_neg (&ans, &wop1);
3193 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
3195 sim_fpu_to32 (&GR[reg3], &ans);
3196 TRACE_FP_RESULT_FPU1 (&ans);
3200 rrrrr,111111,RRRRR + wwwww,101,W,11,WWWW,0:F_I:::nmsubf_s
3202 "nmsubf.s r<reg1>, r<reg2>, r<reg3>, r<reg4>"
3204 sim_fpu ans, wop1, wop2, wop3;
3205 sim_fpu_status status;
3207 sim_fpu_32to (&wop1, GR[reg1]);
3208 sim_fpu_32to (&wop2, GR[reg2]);
3209 sim_fpu_32to (&wop3, GR[reg3]);
3210 TRACE_FP_INPUT_FPU3 (&wop1, &wop2, &wop3);
3212 status = sim_fpu_mul (&ans, &wop1, &wop2);
3213 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3215 status |= sim_fpu_sub (&ans, &wop1, &wop3);
3216 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3218 status |= sim_fpu_neg (&ans, &wop1);
3220 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
3222 sim_fpu_to32 (&GR[reg4], &ans);
3223 TRACE_FP_RESULT_FPU1 (&ans);
3227 rrrrr,111111,RRRRR + wwwww,10011100110:F_I:::fnmsf_s
3229 "fnmsf.s r<reg1>, r<reg2>, r<reg3>"
3231 sim_fpu ans, wop1, wop2, wop3;
3232 sim_fpu_status status;
3234 sim_fpu_32to (&wop1, GR[reg1]);
3235 sim_fpu_32to (&wop2, GR[reg2]);
3236 sim_fpu_32to (&wop3, GR[reg3]);
3237 TRACE_FP_INPUT_FPU3 (&wop1, &wop2, &wop3);
3239 status = sim_fpu_mul (&ans, &wop1, &wop2);
3240 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3242 status |= sim_fpu_sub (&ans, &wop1, &wop3);
3243 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3245 status |= sim_fpu_neg (&ans, &wop1);
3247 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
3249 sim_fpu_to32 (&GR[reg3], &ans);
3250 TRACE_FP_RESULT_FPU1 (&ans);
3254 rrrr,011111100001 + wwww,010001011110:F_I:::recipf.d
3257 "recipf.d r<reg2e>, r<reg3e>"
3260 sim_fpu_status status;
3262 sim_fpu_232to (&wop, GR[reg2e+1], GR[reg2e]);
3263 TRACE_FP_INPUT_FPU1 (&wop);
3265 status = sim_fpu_div (&ans, &sim_fpu_one, &wop);
3266 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3268 update_fpsr (sd, status, FPSR_XEV | FPSR_XEZ | FPSR_XEI | FPSR_XEO | FPSR_XEU, 1);
3270 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &ans);
3271 TRACE_FP_RESULT_FPU1 (&ans);
3275 rrrrr,11111100001 + wwwww,10001001110:F_I:::recipf.s
3278 "recipf.s r<reg2>, r<reg3>"
3281 sim_fpu_status status;
3283 sim_fpu_32to (&wop, GR[reg2]);
3284 TRACE_FP_INPUT_FPU1 (&wop);
3286 status = sim_fpu_div (&ans, &sim_fpu_one, &wop);
3287 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3289 update_fpsr (sd, status, FPSR_XEV | FPSR_XEZ | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
3291 sim_fpu_to32 (&GR[reg3], &ans);
3292 TRACE_FP_RESULT_FPU1 (&ans);
3296 rrrr,011111100010 + wwww,010001011110:F_I:::rsqrtf.d
3299 "rsqrtf.d r<reg2e>, r<reg3e>"
3302 sim_fpu_status status;
3304 sim_fpu_232to (&wop, GR[reg2e+1], GR[reg2e]);
3305 TRACE_FP_INPUT_FPU1 (&wop);
3307 status = sim_fpu_sqrt (&ans, &wop);
3308 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3310 status = sim_fpu_div (&ans, &sim_fpu_one, &wop);
3311 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3313 update_fpsr (sd, status, FPSR_XEV | FPSR_XEZ | FPSR_XEI | FPSR_XEO | FPSR_XEU, 1);
3315 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &ans);
3316 TRACE_FP_RESULT_FPU1 (&ans);
3320 rrrrr,11111100010 + wwwww,10001001110:F_I:::rsqrtf.s
3323 "rsqrtf.s r<reg2>, r<reg3>"
3326 sim_fpu_status status;
3328 sim_fpu_32to (&wop, GR[reg2]);
3329 TRACE_FP_INPUT_FPU1 (&wop);
3331 status = sim_fpu_sqrt (&ans, &wop);
3332 status |= sim_fpu_round_32 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3334 status = sim_fpu_div (&ans, &sim_fpu_one, &wop);
3335 status |= sim_fpu_round_32 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3337 update_fpsr (sd, status, FPSR_XEV | FPSR_XEZ | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
3339 sim_fpu_to32 (&GR[reg3], &ans);
3340 TRACE_FP_RESULT_FPU1 (&ans);
3344 rrrr,011111100000 + wwww,010001011110:F_I:::sqrtf.d
3347 "sqrtf.d r<reg2e>, r<reg3e>"
3350 sim_fpu_status status;
3352 sim_fpu_232to (&wop, GR[reg2e+1], GR[reg2e]);
3353 TRACE_FP_INPUT_FPU1 (&wop);
3355 status = sim_fpu_sqrt (&ans, &wop);
3356 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3358 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI, 1);
3360 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &ans);
3361 TRACE_FP_RESULT_FPU1 (&ans);
3365 rrrrr,11111100000 + wwwww,10001001110:F_I:::sqrtf.s
3368 "sqrtf.s r<reg2>, r<reg3>"
3371 sim_fpu_status status;
3373 sim_fpu_32to (&wop, GR[reg2]);
3374 TRACE_FP_INPUT_FPU1 (&wop);
3376 status = sim_fpu_sqrt (&ans, &wop);
3377 status |= sim_fpu_round_32 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3379 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI, 0);
3381 sim_fpu_to32 (&GR[reg3], &ans);
3382 TRACE_FP_RESULT_FPU1 (&ans);
3386 rrrr,0111111,RRRR,0 + wwww,010001110010:F_I:::subf.d
3389 "subf.d r<reg1e>, r<reg2e>, r<reg3e>"
3391 sim_fpu ans, wop1, wop2;
3392 sim_fpu_status status;
3394 sim_fpu_232to (&wop1, GR[reg1e+1], GR[reg1e]);
3395 sim_fpu_232to (&wop2, GR[reg2e+1], GR[reg2e]);
3396 TRACE_FP_INPUT_FPU2 (&wop1, &wop2);
3398 status = sim_fpu_sub (&ans, &wop2, &wop1);
3399 status |= sim_fpu_round_64 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3401 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 1);
3403 sim_fpu_to232 (&GR[reg3e+1], &GR[reg3e], &ans);
3404 TRACE_FP_RESULT_FPU1 (&ans);
3408 rrrrr,111111,RRRRR + wwwww,10001100010:F_I:::subf.s
3411 "subf.s r<reg1>, r<reg2>, r<reg3>"
3413 sim_fpu ans, wop1, wop2;
3414 sim_fpu_status status;
3416 sim_fpu_32to (&wop1, GR[reg1]);
3417 sim_fpu_32to (&wop2, GR[reg2]);
3418 TRACE_FP_INPUT_FPU2 (&wop1, &wop2);
3420 status = sim_fpu_sub (&ans, &wop2, &wop1);
3421 status |= sim_fpu_round_32 (&ans, FPSR_GET_ROUND(), sim_fpu_denorm_underflow_inexact);
3423 update_fpsr (sd, status, FPSR_XEV | FPSR_XEI | FPSR_XEO | FPSR_XEU, 0);
3425 sim_fpu_to32 (&GR[reg3], &ans);
3426 TRACE_FP_RESULT_FPU1 (&ans);
3430 0000011111100000 + 000001000000,bbb,0:F_I:::trfsr
3436 TRACE_ALU_INPUT1 (GET_FPCC());
3438 if (TEST_FPCC (bbb))
3443 TRACE_ALU_RESULT1 (PSW);
3447 rrrr,011111100001 + wwww,010001010100:F_I:::trncf_dl
3450 "trncf.dl r<reg2e>, r<reg3e>"
3454 sim_fpu_status status;
3456 sim_fpu_232to (&wop, GR[reg2e+1], GR[reg2e]);
3457 TRACE_FP_INPUT_FPU1 (&wop);
3459 status = sim_fpu_to64i (&ans, &wop, sim_fpu_round_zero);
3461 check_cvt_fi(sd, status, 1);
3464 GR[reg3e+1] = ans>>32L;
3465 TRACE_FP_RESULT_WORD2 (GR[reg3e], GR[reg3e+1]);
3469 rrrr,011111110001 + wwww,010001010100:F_I:::trncf_dul
3472 "trncf.dul r<reg2e>, r<reg3e>"
3476 sim_fpu_status status;
3478 sim_fpu_232to (&wop, GR[reg2e+1], GR[reg2e]);
3479 TRACE_FP_INPUT_FPU1 (&wop);
3481 status = sim_fpu_to64u (&ans, &wop, sim_fpu_round_zero);
3483 check_cvt_fi(sd, status, 1);
3486 GR[reg3e+1] = ans>>32L;
3487 TRACE_FP_RESULT_WORD2 (GR[reg3e], GR[reg3e+1]);
3491 rrrr,011111100001 + wwwww,10001010000:F_I:::trncf_dw
3494 "trncf.dw r<reg2e>, r<reg3>"
3498 sim_fpu_status status;
3500 sim_fpu_232to (&wop, GR[reg2e+1], GR[reg2e]);
3501 TRACE_FP_INPUT_FPU1 (&wop);
3503 status = sim_fpu_to32i (&ans, &wop, sim_fpu_round_zero);
3505 check_cvt_fi(sd, status, 1);
3508 TRACE_FP_RESULT_WORD1 (ans);
3512 rrrr,011111110001 + wwwww,10001010000:F_I:::trncf_duw
3515 "trncf.duw r<reg2e>, r<reg3>"
3519 sim_fpu_status status;
3521 sim_fpu_232to (&wop, GR[reg2e+1], GR[reg2e]);
3522 TRACE_FP_INPUT_FPU1 (&wop);
3524 status = sim_fpu_to32u (&ans, &wop, sim_fpu_round_zero);
3526 check_cvt_fi(sd, status, 1);
3529 TRACE_FP_RESULT_WORD1 (ans);
3533 rrrrr,11111100001 + wwww,010001000100:F_I:::trncf_sl
3536 "trncf.sl r<reg2>, r<reg3e>"
3540 sim_fpu_status status;
3542 sim_fpu_32to (&wop, GR[reg2]);
3543 TRACE_FP_INPUT_FPU1 (&wop);
3545 status = sim_fpu_to64i (&ans, &wop, sim_fpu_round_zero);
3548 GR[reg3e+1] = ans >> 32L;
3549 TRACE_FP_RESULT_WORD2 (GR[reg3e], GR[reg3e+1]);
3553 rrrrr,11111110001 + wwww,010001000100:F_I:::trncf_sul
3556 "trncf.sul r<reg2>, r<reg3e>"
3560 sim_fpu_status status;
3562 sim_fpu_32to (&wop, GR[reg2]);
3563 TRACE_FP_INPUT_FPU1 (&wop);
3565 status = sim_fpu_to64u (&ans, &wop, sim_fpu_round_zero);
3568 GR[reg3e+1] = ans >> 32L;
3569 TRACE_FP_RESULT_WORD2 (GR[reg3e], GR[reg3e+1]);
3573 rrrrr,11111100001 + wwwww,10001000000:F_I:::trncf_sw
3576 "trncf.sw r<reg2>, r<reg3>"
3580 sim_fpu_status status;
3582 sim_fpu_32to (&wop, GR[reg2]);
3583 TRACE_FP_INPUT_FPU1 (&wop);
3585 status = sim_fpu_to32i (&ans, &wop, sim_fpu_round_zero);
3587 check_cvt_fi(sd, status, 0);
3590 TRACE_FP_RESULT_WORD1 (ans);
3594 rrrrr,11111110001 + wwwww,10001000000:F_I:::trncf_suw
3597 "trncf.suw r<reg2>, r<reg3>"
3601 sim_fpu_status status;
3603 sim_fpu_32to (&wop, GR[reg2]);
3604 TRACE_FP_INPUT_FPU1 (&wop);
3606 status = sim_fpu_to32u (&ans, &wop, sim_fpu_round_zero);
3608 check_cvt_fi(sd, status, 0);
3611 TRACE_FP_RESULT_WORD1 (ans);
3615 rrrrr,111111,iiiii+wwwww,00011000100:VII:::rotl_imm
3617 "rotl imm5, r<reg2>, r<reg3>"
3619 TRACE_ALU_INPUT1 (GR[reg2]);
3620 v850_rotl (sd, imm5, GR[reg2], & GR[reg3]);
3621 TRACE_ALU_RESULT1 (GR[reg3]);
3624 rrrrr,111111,RRRRR+wwwww,00011000110:VII:::rotl
3626 "rotl r<reg1>, r<reg2>, r<reg3>"
3628 TRACE_ALU_INPUT2 (GR[reg1], GR[reg2]);
3629 v850_rotl (sd, GR[reg1], GR[reg2], & GR[reg3]);
3630 TRACE_ALU_RESULT1 (GR[reg3]);
3634 rrrrr,111111,RRRRR+bbbb,B,0001001,BBB,0:IX:::bins_top
3636 "bins r<reg1>, <bit13> + 16, <bit4> - <bit13> + 17, r<reg2>"
3638 TRACE_ALU_INPUT1 (GR[reg1]);
3639 v850_bins (sd, GR[reg1], bit13 + 16, bit4 + 16, & GR[reg2]);
3640 TRACE_ALU_RESULT1 (GR[reg2]);
3643 rrrrr,111111,RRRRR+bbbb,B,0001011,BBB,0:IX:::bins_middle
3645 "bins r<reg1>, <bit13>, <bit4> - <bit13> + 17, r<reg2>"
3647 TRACE_ALU_INPUT1 (GR[reg1]);
3648 v850_bins (sd, GR[reg1], bit13, bit4 + 16, & GR[reg2]);
3649 TRACE_ALU_RESULT1 (GR[reg2]);
3652 rrrrr,111111,RRRRR+bbbb,B,0001101,BBB,0:IX:::bins_bottom
3654 "bins r<reg1>, <bit13>, <bit4> - <bit13> + 1, r<reg2>"
3656 TRACE_ALU_INPUT1 (GR[reg1]);
3657 v850_bins (sd, GR[reg1], bit13, bit4, & GR[reg2]);
3658 TRACE_ALU_RESULT1 (GR[reg2]);
3661 vvvvv,11111100100+xxxxx,11001111110:C:::cnvq15q30
3663 "cnvq15q30 v<vreg2>, v<vreg3>"
3667 TRACE_ALU_INPUT1 (VR[vreg2]);
3669 if (VR[vreg2] & (1 << 15))
3670 v = 0x0001ffffffff0000 | VR[vreg2];
3673 VR[vreg3] = v << 15;
3675 TRACE_ALU_RESULT1 (VR[vreg3]);
3678 vvvvv,11111100110+xxxxx,11001111110:C:::cnvq30q15
3680 "cnvq30q15 v<vreg2>, v<vreg3>"
3684 TRACE_ALU_INPUT1 (VR[vreg2]);
3686 v = ROUND_Q62_Q15 (VR[vreg2]);
3688 VR[vreg3] &= 0xffffffffffff0000UL;
3692 TRACE_ALU_RESULT1 (VR[vreg3]);
3695 vvvvv,11111100101+xxxxx,11001111110:C:::cnvq31q62
3697 "cnvq31q62 v<vreg2>, v<vreg3>"
3701 TRACE_ALU_INPUT1 (VR[vreg2]);
3703 if (VR[vreg2] & (1 << 31))
3704 v = 0xffffffff00000000 | VR[vreg2];
3707 VR[vreg3] = v << 31;
3709 TRACE_ALU_RESULT1 (VR[vreg3]);
3712 vvvvv,11111100111+xxxxx,11001111110:C:::cnvq62q31
3714 "cnvq62q31 v<vreg2>, v<vreg3>"
3718 TRACE_ALU_INPUT1 (VR[vreg2]);
3720 v = ROUND_Q62_Q31 (VR[vreg2]);
3722 VR[vreg3] &= 0xffffffff00000000UL;
3726 TRACE_ALU_RESULT1 (VR[vreg3]);
3729 vvvvv,111111100,ii+xxxxx,11011011100:C:::dup.h
3731 "dup.h <imm2> v<vreg2>, v<vreg3>"
3735 TRACE_ALU_INPUT1 (VR[vreg2]);
3738 case 0: v = VR[vreg2] & 0xffff; break;
3739 case 1: v = (VR[vreg2] >> 16) & 0xffff; break;
3740 case 2: v = (VR[vreg2] >> 32) & 0xffff; break;
3741 case 3: v = (VR[vreg2] >> 48) & 0xffff; break;
3743 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
3747 VR[vreg3] = v | (v << 16) | (v << 32) | (v << 48);
3748 TRACE_ALU_RESULT1 (VR[vreg3]);
3751 vvvvv,1111111100,i+xxxxx,11011011110:C:::dup.w
3753 "dup.w <imm1> v<vreg2>, v<vreg3>"
3757 TRACE_ALU_INPUT1 (VR[vreg2]);
3760 case 0: v = VR[vreg2] & 0xffffffff; break;
3761 case 1: v = (VR[vreg2] >> 32) & 0xffffffff; break;
3763 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
3767 VR[vreg3] = v | (v << 32);
3768 TRACE_ALU_RESULT1 (VR[vreg3]);
3771 vvvvv,11111101000+xxxxx,11001111110:C:::expq31
3773 "expq31 v<vreg2>, v<vreg3>"
3778 TRACE_ALU_INPUT1 (VR[vreg2]);
3779 v = VR[vreg2] & 0xffffffff;
3782 if (v == 0x80000000)
3784 else if (v == 0xffffffff)
3787 for (i = 31; i; --i)
3788 if ((v & (1 << i)) == 0)
3793 if (v == 0x7fffffff)
3798 for (i = 31; i; --i)
3803 TRACE_ALU_RESULT1 (VR[vreg3]);
3806 rrrr,011111100000+0000011011011000:C:::modadd
3814 TRACE_ALU_INPUT1 (GR[reg2e]);
3818 max = GR[reg2e + 1];
3821 if (inc > 0 && r > max)
3823 else if (inc < 0 && r < 0)
3825 GR[reg2e] = (r & 0xffff) | (inc << 16);
3826 TRACE_ALU_RESULT1 (GR[reg2e]);
3829 vvvvv,11111111000+wwwww,11011011010:C:::mov_dw_to_gr
3831 "mov.dw v<vreg2>, r<reg3>"
3833 TRACE_ALU_INPUT1 (VR[vreg2]);
3834 GR[reg3] = VR[vreg2] & 0xffffffff;
3835 GR[reg3 + 1] = VR[vreg2] >> 32;
3836 TRACE_ALU_RESULT2 (GR[reg3], GR[reg3 + 1]);
3839 rrrrr,11111111100+xxxxx,11011011010:C:::mov_dw_to_vr
3841 "mov.dw r<reg2>, v<vreg3>"
3843 TRACE_ALU_INPUT2 (GR[reg2], GR[reg2 + 1]);
3844 VR[vreg3] = GR[reg2 + 1];
3846 VR[vreg3] |= GR[reg2];
3847 TRACE_ALU_RESULT1 (VR[vreg3]);
3850 vvvvv,111111000,ii+xxxxx,11011011100:C:::mov.h
3852 "mov.h <imm2> v<vreg2>, v<vreg3>"
3854 reg64_t v = VR[vreg2];
3855 reg64_t mask = 0xffffUL;
3858 TRACE_ALU_INPUT1 (VR[vreg2]);
3863 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
3864 case 0: shift = 0; break;
3865 case 1: shift = 16; break;
3866 case 2: shift = 32; break;
3867 case 3: shift = 48; break;
3871 VR[vreg3] &= ~ (mask << shift);
3872 VR[vreg3] |= (v << shift);
3874 TRACE_ALU_RESULT1 (VR[vreg3]);
3877 vvvvv,1111110000,i+xxxxx,11011011010:C:::mov.w.vreg_to_vreg
3879 "mov.w <imm1> v<vreg2>, v<vreg3>"
3881 reg64_t v = VR[vreg2];
3882 reg64_t mask = 0xffffffffUL;
3885 TRACE_ALU_INPUT1 (VR[vreg2]);
3889 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
3890 case 0: shift = 0; break;
3891 case 1: shift = 32; break;
3895 VR[vreg3] &= ~ (mask << shift);
3896 VR[vreg3] |= (v << shift);
3898 TRACE_ALU_RESULT1 (VR[vreg3]);
3901 rrrrr,1111111000,i+xxxxx,11011011010:C:::mov.w.reg_to_vreg
3903 "mov.w <imm1> r<reg2>, v<vreg3>"
3906 reg64_t mask = 0xffffffffUL;
3909 TRACE_ALU_INPUT1 (GR[reg2]);
3913 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
3914 case 0: shift = 0; break;
3915 case 1: shift = 32; break;
3919 VR[vreg3] &= ~ (mask << shift);
3920 VR[vreg3] |= (v << shift);
3922 TRACE_ALU_RESULT1 (VR[vreg3]);
3925 vvvvv,1111110100,i+wwwww,11011011010:C:::mov.w.vreg_to_reg
3927 "mov.w <imm1> v<vreg2>, r<reg3>"
3929 TRACE_ALU_INPUT1 (VR[vreg2]);
3934 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
3936 GR[reg3] = VR[vreg2];
3939 GR[reg3] = VR[vreg2] >> 32;
3943 TRACE_ALU_RESULT1 (GR[reg3]);
3946 vvvvv,111111,VVVVV+xxxxx,11001101010:C:::pki16i32
3948 "pki16i32 v<vreg1>, v<vreg2>, v<vreg3>"
3952 TRACE_ALU_INPUT1 (VR[vreg1]);
3955 VR[vreg2] = (SEXT32 (v, 16) & 0xffffffff);
3958 VR[vreg2] |= t << 32;
3961 VR[vreg3] = (SEXT32 (v, 16) & 0xffffffff);
3964 VR[vreg3] |= t << 32;
3966 TRACE_ALU_RESULT2 (VR[vreg2], VR[vreg3]);
3969 vvvvv,111111,VVVVV+xxxxx,11001100110:C:::pki16ui8
3971 "pki16ui8 v<vreg1>, v<vreg2>, v<vreg3>"
3973 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
3975 VR[vreg3] = VR[vreg1] & 0xff;
3976 VR[vreg3] |= ((VR[vreg1] >> 8) & 0xff00);
3977 VR[vreg3] |= ((VR[vreg1] >> 16) & 0xff0000);
3978 VR[vreg3] |= ((VR[vreg1] >> 24) & 0xff000000);
3980 VR[vreg3] |= ((VR[vreg2] << 32) & 0xff00000000UL);
3981 VR[vreg3] |= ((VR[vreg2] << 24) & 0xff0000000000UL);
3982 VR[vreg3] |= ((VR[vreg2] << 16) & 0xff000000000000UL);
3983 VR[vreg3] |= ((VR[vreg2] << 8) & 0xff00000000000000UL);
3985 TRACE_ALU_RESULT1 (VR[vreg3]);
3988 vvvvv,111111,VVVVV+xxxxx,11001100100:C:::pki32i16
3990 "pki32i16 v<vreg1>, v<vreg2>, v<vreg3>"
3994 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
3996 v = VR[vreg1] & 0xffffffff;
3998 VR[vreg3] = v & 0xffff;
4000 v = VR[vreg1] >> 32;
4002 VR[vreg3] |= ((v & 0xffff) << 16);
4004 v = VR[vreg2] & 0xffffffff;
4006 VR[vreg3] = ((v & 0xffff) << 32);
4008 v = VR[vreg2] >> 32;
4010 VR[vreg3] |= ((v & 0xffff) << 48);
4012 TRACE_ALU_RESULT1 (VR[vreg3]);
4015 vvvvv,111111,VVVVV+xxxxx,11001100010:C:::pki64i32
4017 "pki64i32 v<vreg1>, v<vreg2>, v<vreg3>"
4021 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4025 VR[vreg3] = v & 0xffffffff;
4029 VR[vreg3] |= v << 32;
4031 TRACE_ALU_RESULT1 (VR[vreg3]);
4034 vvvvv,111111,VVVVV+xxxxx,11001101000:C:::pkq15q31
4036 "pkq15q31 v<vreg1>, v<vreg2>, v<vreg3>"
4040 TRACE_ALU_INPUT1 (VR[vreg1]);
4043 VR[vreg2] = ((v & 0xffff) << 16);
4044 VR[vreg2] |= ((v & 0xffff0000) << 32);
4046 VR[vreg3] = ((v & 0xffff00000000UL) >> 16);
4047 VR[vreg3] |= ((v & 0xffff000000000000UL));
4049 TRACE_ALU_RESULT2 (VR[vreg2], VR[vreg3]);
4052 vvvvv,111111,VVVVV+xxxxx,11001011110:C:::pkq30q31
4054 "pkq30q31 v<vreg1>, v<vreg2>, v<vreg3>"
4058 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4063 VR[vreg3] = v & 0xffffffff;
4068 VR[vreg3] = v << 32;
4070 TRACE_ALU_RESULT1 (VR[vreg3]);
4073 vvvvv,111111,VVVVV+xxxxx,11001100000:C:::pkq31q15
4075 "pkq31q15 v<vreg1>, v<vreg2>, v<vreg3>"
4079 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4081 v = ROUND_Q31_Q15 (VR[vreg1] & 0xffffffff);
4083 VR[vreg3] = v & 0xffff;
4085 v = ROUND_Q31_Q15 (VR[vreg1] >> 32);
4087 VR[vreg3] |= (v & 0xffff) << 16;
4089 v = ROUND_Q31_Q15 (VR[vreg2] & 0xffffffff);
4091 VR[vreg3] |= (v & 0xffff) << 32;
4093 v = ROUND_Q31_Q15 (VR[vreg2] >> 32);
4095 VR[vreg3] |= (v & 0xffff) << 48;
4097 TRACE_ALU_RESULT1 (VR[vreg3]);
4100 vvvvv,111111,VVVVV+xxxxx,11001101100:C:::pkui8i16
4102 "pkui8i16 v<vreg1>, v<vreg2>, v<vreg3>"
4106 TRACE_ALU_INPUT1 (VR[vreg1]);
4110 VR[vreg2] = v & 0x00ff;
4111 VR[vreg2] |= (v << 8) & 0x00ff0000;
4112 VR[vreg2] |= (v << 16) & 0x00ff00000000UL;
4113 VR[vreg2] |= (v << 24) & 0x00ff000000000000UL;
4115 VR[vreg3] = (v >> 32) & 0x00ff;
4116 VR[vreg3] |= (v >> 24) & 0x00ff0000;
4117 VR[vreg3] |= (v >> 16) & 0x00ff00000000UL;
4118 VR[vreg3] |= (v >> 8) & 0x00ff000000000000UL;
4120 TRACE_ALU_RESULT2 (VR[vreg2], VR[vreg3]);
4123 vvvvv,11111100000+xxxxx,11001111110:C:::vabs.h
4125 "vabs.h v<vreg2>, v<vreg3>"
4129 TRACE_ALU_INPUT1 (VR[vreg2]);
4132 for (shift = 0; shift < 64; shift += 16);
4136 v = VR[vreg2] >> shift;
4138 VR[vreg3] |= v << shift;
4141 TRACE_ALU_RESULT1 (VR[vreg3]);
4144 vvvvv,11111100001+xxxxx,11001111110:C:::vabs.w
4146 "vabs.w v<vreg2>, v<vreg3>"
4150 TRACE_ALU_INPUT1 (VR[vreg2]);
4156 v = VR[vreg2] >> 32;
4158 VR[vreg3] |= v << 32;
4160 TRACE_ALU_RESULT1 (VR[vreg3]);
4163 vvvvv,111111,VVVVV+xxxxx,11001011000:C:::vadd.dw
4165 "vadd.dw v<vreg1>, v<vreg2>, v<vreg3>"
4167 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4169 /* FIXME: saturation handling needed. */
4170 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4172 VR[vreg3] = VR[vreg1] + VR[vreg2];
4174 TRACE_ALU_RESULT1 (VR[vreg3]);
4177 vvvvv,111111,VVVVV+xxxxx,11000000000:C:::vadd.h
4179 "vadd.h v<vreg1>, v<vreg2>, v<vreg3>"
4181 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4183 /* FIXME: Implementation needed. */
4184 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4186 TRACE_ALU_RESULT1 (VR[vreg3]);
4189 vvvvv,111111,VVVVV+xxxxx,11000000010:C:::vadd.w
4191 "vadd.w v<vreg1>, v<vreg2>, v<vreg3>"
4193 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4195 /* FIXME: Implementation needed. */
4196 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4198 TRACE_ALU_RESULT1 (VR[vreg3]);
4201 vvvvv,111111,VVVVV+xxxxx,11000001000:C:::vadds.h
4203 "vadds.h v<vreg1>, v<vreg2>, v<vreg3>"
4205 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4207 /* FIXME: Implementation needed. */
4208 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4210 TRACE_ALU_RESULT1 (VR[vreg3]);
4213 vvvvv,111111,VVVVV+xxxxx,11000001010:C:::vadds.w
4215 "vadds.w v<vreg1>, v<vreg2>, v<vreg3>"
4217 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4219 /* FIXME: Implementation needed. */
4220 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4222 TRACE_ALU_RESULT1 (VR[vreg3]);
4225 vvvvv,111111,VVVVV+xxxxx,11000010000:C:::vaddsat.h
4227 "vaddsat.h v<vreg1>, v<vreg2>, v<vreg3>"
4229 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4231 /* FIXME: Implementation needed. */
4232 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4234 TRACE_ALU_RESULT1 (VR[vreg3]);
4237 vvvvv,111111,VVVVV+xxxxx,11000010010:C:::vaddsat.w
4239 "vaddsat.w v<vreg1>, v<vreg2>, v<vreg3>"
4241 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4243 /* FIXME: Implementation needed. */
4244 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4246 TRACE_ALU_RESULT1 (VR[vreg3]);
4249 vvvvv,111111,VVVVV+xxxxx,11010000000:C:::vand
4251 "vand v<vreg1>, v<vreg2>, v<vreg3>"
4253 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4255 VR[vreg3] = VR[vreg1] & VR[vreg2];
4257 TRACE_ALU_RESULT1 (VR[vreg3]);
4260 vvvvv,111111,VVVVV+xxxxx,11001011100:C:::vbiq.h
4262 "vbiq.h v<vreg1>, v<vreg2>, v<vreg3>"
4264 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4266 /* FIXME: Implementation needed. */
4267 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4269 TRACE_ALU_RESULT2 (VR[vreg2], VR[vreg3]);
4272 vvvvv,11111100111+xxxxx,11011011110:C:::vbswap.dw
4274 "vbswap.dw v<vreg2>, v<vreg3>"
4276 TRACE_ALU_INPUT1 (VR[vreg2]);
4278 /* FIXME: Implementation needed. */
4279 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4281 TRACE_ALU_RESULT1 (VR[vreg3]);
4284 vvvvv,11111100101+xxxxx,11011011110:C:::vbswap.h
4286 "vbswap.h v<vreg2>, v<vreg3>"
4288 TRACE_ALU_INPUT1 (VR[vreg2]);
4290 /* FIXME: Implementation needed. */
4291 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4293 TRACE_ALU_RESULT1 (VR[vreg3]);
4296 vvvvv,11111100110+xxxxx,11011011110:C:::vbswap.w
4298 "vbswap.w v<vreg2>, v<vreg3>"
4300 TRACE_ALU_INPUT1 (VR[vreg2]);
4302 /* FIXME: Implementation needed. */
4303 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4305 TRACE_ALU_RESULT1 (VR[vreg3]);
4308 vvvvv,111111,VVVVV+xxxxx,11001110000:C:::vcalc.h
4310 "vcalc.h v<vreg1>,v<vreg2>, v<vreg3>"
4312 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4314 /* FIXME: Implementation needed. */
4315 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4317 TRACE_ALU_RESULT1 (VR[vreg3]);
4320 vvvvv,111111,VVVVV+xxxxx,11001110010:C:::vcalc.w
4322 "vcalc.w v<vreg1>,v<vreg2>, v<vreg3>"
4324 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4326 /* FIXME: Implementation needed. */
4327 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4329 TRACE_ALU_RESULT1 (VR[vreg3]);
4332 vvvvv,111111,VVVVV+xxxxx,11010110000:C:::vcmov
4334 "vcmov v<vreg1>, v<vreg2>, v<vreg3>"
4336 TRACE_ALU_INPUT2 (VR[vreg1], VR[vreg2]);
4338 /* FIXME: Implementation needed. */
4339 sim_engine_halt (SD, CPU, NULL, cia, sim_signalled, SIM_SIGILL);
4341 TRACE_ALU_RESULT1 (VR[vreg3]);