* interp.c (hash): Update to be more accurate.
[deliverable/binutils-gdb.git] / sim / v850 / simops.c
CommitLineData
22c1c7dd
JL
1#include <signal.h>
2#include "v850_sim.h"
3#include "simops.h"
4
22c1c7dd
JL
5void
6OP_220 ()
7{
8}
9
10void
11OP_10760 ()
12{
13}
14
15void
16OP_C7C0 ()
17{
18}
19
20void
21OP_760 ()
22{
23}
24
22c1c7dd
JL
25void
26OP_580 ()
27{
28}
29
30void
31OP_700 ()
32{
33}
34
35void
36OP_581 ()
37{
38}
39
22c1c7dd
JL
40void
41OP_582 ()
42{
43}
44
45void
46OP_583 ()
47{
48}
49
50void
51OP_584 ()
52{
53}
54
55void
56OP_585 ()
57{
58}
59
60void
61OP_586 ()
62{
63}
64
65void
66OP_587 ()
67{
68}
69
70void
71OP_588 ()
72{
73}
74
75void
76OP_589 ()
77{
78}
79
80void
81OP_58A ()
82{
83}
84
85void
86OP_58B ()
87{
88}
89
90void
91OP_58C ()
92{
93}
94
95void
96OP_400 ()
97{
98}
99
22c1c7dd
JL
100void
101OP_160 ()
102{
103}
104
105void
106OP_58D ()
107{
108}
109
110void
111OP_58E ()
112{
113}
114
115void
116OP_58F ()
117{
118}
119
120void
121OP_660 ()
122{
123}
124
22c1c7dd 125
0ef0eba5 126/* add reg, reg */
22c1c7dd 127void
1fe983dc 128OP_1C0 ()
22c1c7dd 129{
0ef0eba5 130 unsigned int op0, op1, result, z, s, cy, ov;
22c1c7dd 131
0ef0eba5
JL
132 /* Compute the result. */
133 op0 = State.regs[OP[0]];
134 op1 = State.regs[OP[1]];
135 result = op0 + op1;
1fe983dc 136
0ef0eba5
JL
137 /* Compute the condition codes. */
138 z = (result == 0);
139 s = (result & 0x80000000);
140 cy = (result < op0 || result < op1);
141 ov = ((op0 & 0x80000000) == (op1 & 0x80000000)
142 && (op0 & 0x80000000) != (result & 0x80000000));
143
144 /* Store the result and condition codes. */
145 State.regs[OP[1]] = result;
146 State.psw &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
147 State.psw |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
148 | (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
149}
150
151/* add sign_extend(imm5), reg */
22c1c7dd 152void
1fe983dc 153OP_240 ()
22c1c7dd 154{
0ef0eba5
JL
155 unsigned int op0, op1, result, z, s, cy, ov;
156 int temp;
1fe983dc 157
0ef0eba5
JL
158 /* Compute the result. */
159 temp = (OP[0] & 0x1f);
160 temp = (temp << 27) >> 27;
161 op0 = temp;
162 op1 = State.regs[OP[1]];
163 result = op0 + op1;
164
165 /* Compute the condition codes. */
166 z = (result == 0);
167 s = (result & 0x80000000);
168 cy = (result < op0 || result < op1);
169 ov = ((op0 & 0x80000000) == (op1 & 0x80000000)
170 && (op0 & 0x80000000) != (result & 0x80000000));
22c1c7dd 171
0ef0eba5
JL
172 /* Store the result and condition codes. */
173 State.regs[OP[1]] = result;
174 State.psw &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
175 State.psw |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
176 | (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
177}
1fe983dc 178
0ef0eba5 179/* addi sign_extend(imm16), reg, reg */
22c1c7dd 180void
1fe983dc 181OP_600 ()
22c1c7dd 182{
0ef0eba5
JL
183 unsigned int op0, op1, result, z, s, cy, ov;
184 int temp;
185
186 /* Compute the result. */
187 temp = (OP[0] & 0xffff);
188 temp = (temp << 16) >> 16;
189 op0 = temp;
190 op1 = State.regs[OP[1]];
191 result = op0 + op1;
192
193 /* Compute the condition codes. */
194 z = (result == 0);
195 s = (result & 0x80000000);
196 cy = (result < op0 || result < op1);
197 ov = ((op0 & 0x80000000) == (op1 & 0x80000000)
198 && (op0 & 0x80000000) != (result & 0x80000000));
199
200 /* Store the result and condition codes. */
201 State.regs[OP[2]] = result;
202 State.psw &= ~(PSW_Z | PSW_S | PSW_CY | PSW_OV);
203 State.psw |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0)
204 | (cy ? PSW_CY : 0) | (ov ? PSW_OV : 0));
22c1c7dd
JL
205}
206
1fe983dc
JL
207/* sub reg1, reg2
208
209 XXX condition codes */
22c1c7dd 210void
1fe983dc 211OP_1A0 ()
22c1c7dd 212{
1fe983dc 213 State.regs[OP[1]] -= State.regs[OP[0]];
22c1c7dd
JL
214}
215
1fe983dc
JL
216/* subr reg1, reg2
217
218 XXX condition codes */
22c1c7dd 219void
1fe983dc 220OP_180 ()
22c1c7dd 221{
1fe983dc 222 State.regs[OP[1]] = State.regs[OP[0]] - State.regs[OP[1]];
22c1c7dd
JL
223}
224
e98e3b2c
JL
225/* mulh reg1, reg2
226
227 XXX condition codes */
22c1c7dd 228void
e98e3b2c 229OP_E0 ()
22c1c7dd 230{
e98e3b2c 231 State.regs[OP[1]] = ((State.regs[OP[1]] & 0xffff)
fb8eb42b 232 * (State.regs[OP[0]] & 0xffff));
22c1c7dd
JL
233}
234
e98e3b2c
JL
235/* mulh sign_extend(imm5), reg2
236
237 Condition codes */
22c1c7dd 238void
e98e3b2c 239OP_2E0 ()
22c1c7dd 240{
e98e3b2c
JL
241 int value = OP[0];
242
243 value = (value << 27) >> 27;
244
245 State.regs[OP[1]] = (State.regs[OP[1]] & 0xffff) * value;
22c1c7dd
JL
246}
247
e98e3b2c
JL
248/* mulhi imm16, reg1, reg2
249
250 XXX condition codes */
22c1c7dd 251void
e98e3b2c
JL
252OP_6E0 ()
253{
254 int value = OP[0];
255
256 value = value & 0xffff;
257
fb8eb42b 258 State.regs[OP[2]] = (State.regs[OP[1]] & 0xffff) * value;
e98e3b2c
JL
259}
260
261/* divh reg1, reg2
262
263 XXX condition codes.
264 XXX Is this signed or unsigned? */
265void
266OP_40 ()
22c1c7dd 267{
fb8eb42b 268 State.regs[OP[1]] /= (State.regs[OP[0]] & 0xffff);
22c1c7dd
JL
269}
270
22c1c7dd 271void
1fe983dc 272OP_10720 ()
22c1c7dd
JL
273{
274}
275
276void
1fe983dc 277OP_780 ()
22c1c7dd
JL
278{
279}
280
281void
282OP_720 ()
283{
284}
285
286void
287OP_60 ()
288{
289}
290
22c1c7dd
JL
291void
292OP_87C0 ()
293{
294}
295
22c1c7dd
JL
296void
297OP_300 ()
298{
299}
300
1fe983dc 301/* mov reg, reg */
22c1c7dd
JL
302void
303OP_0 ()
304{
1fe983dc 305 State.regs[OP[1]] = State.regs[OP[0]];
22c1c7dd
JL
306}
307
1fe983dc 308/* mov sign_extend(imm5), reg */
22c1c7dd 309void
1fe983dc 310OP_200 ()
22c1c7dd 311{
1fe983dc
JL
312 int value = OP[0];
313
314 value = (value << 27) >> 27;
315 State.regs[OP[1]] = value;
22c1c7dd
JL
316}
317
1fe983dc
JL
318/* movea sign_extend(imm16), reg, reg */
319
22c1c7dd 320void
1fe983dc 321OP_620 ()
22c1c7dd 322{
1fe983dc
JL
323 int value = OP[0];
324
325 value = (value << 16) >> 16;
326
327 State.regs[OP[2]] = State.regs[OP[1]] + value;
22c1c7dd
JL
328}
329
1fe983dc 330/* movhi imm16, reg, reg */
22c1c7dd 331void
1fe983dc 332OP_640 ()
22c1c7dd 333{
1fe983dc
JL
334 int value = OP[0];
335
336 value = (value & 0xffff) << 16;
337
338 State.regs[OP[2]] = State.regs[OP[1]] + value;
22c1c7dd
JL
339}
340
341void
1fe983dc 342OP_7C0 ()
22c1c7dd
JL
343{
344}
345
346void
1fe983dc 347OP_1687E0 ()
22c1c7dd
JL
348{
349}
350
351void
352OP_1E0 ()
353{
354}
355
356void
357OP_A0 ()
358{
359}
360
361void
362OP_260 ()
363{
364}
365
22c1c7dd
JL
366void
367OP_740 ()
368{
369}
370
371void
372OP_80 ()
373{
374}
375
77553374
JL
376/* sar zero_extend(imm5),reg1
377
378 XXX condition codes. */
22c1c7dd 379void
77553374 380OP_2A0 ()
22c1c7dd 381{
77553374
JL
382 int temp = State.regs[OP[1]];
383
384 temp >>= (OP[0] & 0x1f);
385
386 State.regs[OP[1]] = temp;
22c1c7dd
JL
387}
388
77553374
JL
389/* sar reg1, reg2
390
391 XXX condition codes. */
22c1c7dd 392void
77553374 393OP_A007E0 ()
22c1c7dd 394{
77553374
JL
395 int temp = State.regs[OP[1]];
396
397 temp >>= (State.regs[OP[0]] & 0x1f);
398
399 State.regs[OP[1]] = temp;
22c1c7dd
JL
400}
401
77553374
JL
402/* shl zero_extend(imm5),reg1
403
404 XXX condition codes. */
22c1c7dd
JL
405void
406OP_2C0 ()
77553374
JL
407{
408 State.regs[OP[1]] <<= (OP[0] & 0x1f);
409}
410
411/* shl reg1, reg2
412
413 XXX condition codes. */
414void
415OP_C007E0 ()
416{
417 State.regs[OP[1]] <<= (State.regs[OP[0]] & 0x1f);
418}
419
420/* shr zero_extend(imm5),reg1
421
422 XXX condition codes. */
423void
424OP_280 ()
425{
426 State.regs[OP[1]] >>= (OP[0] & 0x1f);
427}
428
429/* shr reg1, reg2
430
431 XXX condition codes. */
432void
433OP_8007E0 ()
434{
435 State.regs[OP[1]] >>= (State.regs[OP[0]] & 0x1f);
436}
437
438void
439OP_500 ()
22c1c7dd
JL
440{
441}
442
22c1c7dd
JL
443void
444OP_47C0 ()
445{
446}
447
22c1c7dd
JL
448void
449OP_7E0 ()
450{
451}
452
0ef0eba5 453/* or reg, reg */
1fe983dc
JL
454void
455OP_100 ()
456{
0ef0eba5 457 unsigned int op0, op1, result, z, s, cy, ov;
1fe983dc 458
0ef0eba5
JL
459 /* Compute the result. */
460 op0 = State.regs[OP[0]];
461 op1 = State.regs[OP[1]];
462 result = op0 | op1;
1fe983dc 463
0ef0eba5
JL
464 /* Compute the condition codes. */
465 z = (result == 0);
466 s = (result & 0x80000000);
467
468 /* Store the result and condition codes. */
469 State.regs[OP[1]] = result;
470 State.psw &= ~(PSW_Z | PSW_S | PSW_OV);
471 State.psw |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
472}
473
474/* ori zero_extend(imm16), reg, reg */
1fe983dc
JL
475void
476OP_680 ()
477{
0ef0eba5 478 unsigned int op0, op1, result, z, s, cy, ov;
1fe983dc 479
0ef0eba5
JL
480 op0 = OP[0] & 0xffff;
481 op1 = State.regs[OP[1]];
482 result = op0 | op1;
1fe983dc 483
0ef0eba5
JL
484 /* Compute the condition codes. */
485 z = (result == 0);
486 s = (result & 0x80000000);
1fe983dc 487
0ef0eba5
JL
488 /* Store the result and condition codes. */
489 State.regs[OP[2]] = result;
490 State.psw &= ~(PSW_Z | PSW_S | PSW_OV);
491 State.psw |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
492 State.psw |= (z ? PSW_Z : 0);
493}
494
495/* and reg, reg */
22c1c7dd
JL
496void
497OP_140 ()
498{
0ef0eba5 499 unsigned int op0, op1, result, z, s, cy, ov;
22c1c7dd 500
0ef0eba5
JL
501 /* Compute the result. */
502 op0 = State.regs[OP[0]];
503 op1 = State.regs[OP[1]];
504 result = op0 & op1;
1fe983dc 505
0ef0eba5
JL
506 /* Compute the condition codes. */
507 z = (result == 0);
508 s = (result & 0x80000000);
509
510 /* Store the result and condition codes. */
511 State.regs[OP[1]] = result;
512 State.psw &= ~(PSW_Z | PSW_S | PSW_OV);
513 State.psw |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
514}
515
516/* andi zero_extend(imm16), reg, reg */
22c1c7dd 517void
1fe983dc
JL
518OP_6C0 ()
519{
0ef0eba5 520 unsigned int op0, op1, result, z, s, cy, ov;
1fe983dc 521
0ef0eba5
JL
522 op0 = OP[0] & 0xffff;
523 op1 = State.regs[OP[1]];
524 result = op0 & op1;
1fe983dc 525
0ef0eba5
JL
526 /* Compute the condition codes. */
527 z = (result == 0);
1fe983dc 528
0ef0eba5
JL
529 /* Store the result and condition codes. */
530 State.regs[OP[2]] = result;
531 State.psw &= ~(PSW_Z | PSW_S | PSW_OV);
532 State.psw |= (z ? PSW_Z : 0);
533}
534
535/* xor reg, reg */
1fe983dc
JL
536void
537OP_120 ()
22c1c7dd 538{
0ef0eba5 539 unsigned int op0, op1, result, z, s, cy, ov;
1fe983dc 540
0ef0eba5
JL
541 /* Compute the result. */
542 op0 = State.regs[OP[0]];
543 op1 = State.regs[OP[1]];
544 result = op0 ^ op1;
1fe983dc 545
0ef0eba5
JL
546 /* Compute the condition codes. */
547 z = (result == 0);
548 s = (result & 0x80000000);
549
550 /* Store the result and condition codes. */
551 State.regs[OP[1]] = result;
552 State.psw &= ~(PSW_Z | PSW_S | PSW_OV);
553 State.psw |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
554}
555
556/* xori zero_extend(imm16), reg, reg */
1fe983dc
JL
557void
558OP_6A0 ()
559{
0ef0eba5
JL
560 unsigned int op0, op1, result, z, s, cy, ov;
561
562 op0 = OP[0] & 0xffff;
563 op1 = State.regs[OP[1]];
564 result = op0 ^ op1;
565
566 /* Compute the condition codes. */
567 z = (result == 0);
568 s = (result & 0x80000000);
569
570 /* Store the result and condition codes. */
571 State.regs[OP[2]] = result;
572 State.psw &= ~(PSW_Z | PSW_S | PSW_OV);
573 State.psw |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
574 State.psw |= (z ? PSW_Z : 0);
575}
576
577/* not reg1, reg2 */
578void
579OP_20 ()
580{
581 unsigned int op0, result, z, s, cy, ov;
582
583 /* Compute the result. */
584 op0 = State.regs[OP[0]];
585 result = ~op0;
586
587 /* Compute the condition codes. */
588 z = (result == 0);
589 s = (result & 0x80000000);
1fe983dc 590
0ef0eba5
JL
591 /* Store the result and condition codes. */
592 State.regs[OP[1]] = result;
593 State.psw &= ~(PSW_Z | PSW_S | PSW_OV);
594 State.psw |= ((z ? PSW_Z : 0) | (s ? PSW_S : 0));
22c1c7dd
JL
595}
596
597void
598OP_C0 ()
599{
600}
601
1fe983dc
JL
602void
603OP_480 ()
604{
605}
606
607void
608OP_380 ()
609{
610}
611
612void
613OP_501 ()
614{
615}
e98e3b2c
JL
616
617/* di, not supported */
618void
619OP_16007E0 ()
620{
621 abort ();
622}
623
624/* ei, not supported */
625void
626OP_16087E0 ()
627{
628 abort ();
629}
630
631/* halt, not supported */
632void
633OP_12007E0 ()
634{
635 abort ();
636}
637
638/* reti, not supported */
639void
640OP_14007E0 ()
641{
642 abort ();
643}
644
645/* trap, not supportd */
646void
647OP_10007E0 ()
648{
649 abort ();
650}
651
652/* ldsr, not supported */
653void
654OP_2007E0 ()
655{
656 abort ();
657}
658
659/* stsr, not supported */
660void
661OP_4007E0 ()
662{
663 abort ();
664}
665
This page took 0.049755 seconds and 4 git commands to generate.