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