1 /* Simulation code for the CR16 processor.
2 Copyright (C) 2008-2022 Free Software Foundation, Inc.
5 This file is part of GDB, the GNU debugger.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* This must come before any other includes. */
25 #include <sys/types.h>
35 #include "sim-signal.h"
37 #include "target-newlib-syscall.h"
44 #define EXCEPTION(sig) sim_engine_halt (sd, cpu, NULL, PC, sim_stopped, sig)
105 PSR_MASK = (PSR_I_BIT
115 /* The following bits in the PSR _can't_ be set by instructions such
117 PSR_HW_MASK = (PSR_MASK)
120 /* cond Code Condition True State
121 * EQ Equal Z flag is 1
122 * NE Not Equal Z flag is 0
123 * CS Carry Set C flag is 1
124 * CC Carry Clear C flag is 0
125 * HI Higher L flag is 1
126 * LS Lower or Same L flag is 0
127 * GT Greater Than N flag is 1
128 * LE Less Than or Equal To N flag is 0
129 * FS Flag Set F flag is 1
130 * FC Flag Clear F flag is 0
131 * LO Lower Z and L flags are 0
132 * HS Higher or Same Z or L flag is 1
133 * LT Less Than Z and N flags are 0
134 * GE Greater Than or Equal To Z or N flag is 1. */
136 static int cond_stat(int cc)
140 case 0: return PSR_Z; break;
141 case 1: return !PSR_Z; break;
142 case 2: return PSR_C; break;
143 case 3: return !PSR_C; break;
144 case 4: return PSR_L; break;
145 case 5: return !PSR_L; break;
146 case 6: return PSR_N; break;
147 case 7: return !PSR_N; break;
148 case 8: return PSR_F; break;
149 case 9: return !PSR_F; break;
150 case 10: return !PSR_Z && !PSR_L; break;
151 case 11: return PSR_Z || PSR_L; break;
152 case 12: return !PSR_Z && !PSR_N; break;
153 case 13: return PSR_Z || PSR_N; break;
154 case 14: return 1; break; /*ALWAYS. */
156 // case NEVER: return false; break;
158 //panic("Shouldn't have NO_COND_CODE in an actual instruction!");
166 move_to_cr (SIM_DESC sd, SIM_CPU *cpu, int cr, creg_t mask, creg_t val, int psw_hw_p)
168 /* A MASK bit is set when the corresponding bit in the CR should
170 /* This assumes that (VAL & MASK) == 0. */
181 "ERROR at PC 0x%x: ST can only be set when FX is set.\n", PC);
182 EXCEPTION (SIM_SIGILL);
184 /* keep an up-to-date psw around for tracing. */
185 State.trace.psw = (State.trace.psw & mask) | val;
190 /* only issue an update if the register is being changed. */
191 if ((State.cregs[cr] & ~mask) != val)
192 SLOT_PEND_MASK (State.cregs[cr], mask, val);
198 static void trace_input_func (SIM_DESC sd,
204 #define trace_input(name, in1, in2, in3) do { if (cr16_debug) trace_input_func (sd, name, in1, in2, in3); } while (0)
206 #ifndef SIZE_INSTRUCTION
207 #define SIZE_INSTRUCTION 8
210 #ifndef SIZE_OPERANDS
211 #define SIZE_OPERANDS 18
215 #define SIZE_VALUES 13
218 #ifndef SIZE_LOCATION
219 #define SIZE_LOCATION 20
226 #ifndef SIZE_LINE_NUMBER
227 #define SIZE_LINE_NUMBER 2
231 trace_input_func (SIM_DESC sd, const char *name, enum op_types in1, enum op_types in2, enum op_types in3)
240 const char *filename;
241 const char *functionname;
242 unsigned int linenumber;
245 if ((cr16_debug & DEBUG_TRACE) == 0)
248 switch (State.ins_type)
251 case INS_UNKNOWN: type = " ?"; break;
254 if ((cr16_debug & DEBUG_LINE_NUMBER) == 0)
257 SIZE_PC, (unsigned)PC,
259 SIZE_INSTRUCTION, name);
265 if (STATE_TEXT_SECTION (sd)
266 && byte_pc >= STATE_TEXT_START (sd)
267 && byte_pc < STATE_TEXT_END (sd))
269 filename = (const char *)0;
270 functionname = (const char *)0;
272 if (bfd_find_nearest_line (STATE_PROG_BFD (sd),
273 STATE_TEXT_SECTION (sd),
274 (struct bfd_symbol **)0,
275 byte_pc - STATE_TEXT_START (sd),
276 &filename, &functionname, &linenumber))
281 sprintf (p, "#%-*d ", SIZE_LINE_NUMBER, linenumber);
286 sprintf (p, "%-*s ", SIZE_LINE_NUMBER+1, "---");
287 p += SIZE_LINE_NUMBER+2;
292 sprintf (p, "%s ", functionname);
297 char *q = strrchr (filename, '/');
298 sprintf (p, "%s ", (q) ? q+1 : filename);
308 "0x%.*x %s: %-*.*s %-*s ",
309 SIZE_PC, (unsigned)PC,
311 SIZE_LOCATION, SIZE_LOCATION, buf,
312 SIZE_INSTRUCTION, name);
320 for (i = 0; i < 3; i++)
329 sprintf (p, "%sr%d", comma, OP[i]);
335 sprintf (p, "%scr%d", comma, OP[i]);
341 sprintf (p, "%s%d", comma, OP[i]);
347 sprintf (p, "%s%d", comma, SEXT4(OP[i]));
353 sprintf (p, "%s%d", comma, SEXT3(OP[i]));
359 sprintf (p, "%s@r%d", comma, OP[i]);
365 sprintf (p, "%s@(%d,r%d)", comma, (int16_t)OP[i], OP[i+1]);
371 sprintf (p, "%s@%d", comma, OP[i]);
378 if ((cr16_debug & DEBUG_VALUES) == 0)
382 sim_io_printf (sd, "%s", buf);
387 sim_io_printf (sd, "%-*s", SIZE_OPERANDS, buf);
390 for (i = 0; i < 3; i++)
396 sim_io_printf (sd, "%*s", SIZE_VALUES, "");
400 sim_io_printf (sd, "%*s0x%.4x", SIZE_VALUES-6, "",
401 (uint16_t) GPR (OP[i]));
405 tmp = (long)((((uint32_t) GPR (OP[i])) << 16) | ((uint32_t) GPR (OP[i] + 1)));
406 sim_io_printf (sd, "%*s0x%.8lx", SIZE_VALUES-10, "", tmp);
410 sim_io_printf (sd, "%*s0x%.4x", SIZE_VALUES-6, "",
411 (uint16_t) CREG (OP[i]));
415 sim_io_printf (sd, "%*s0x%.4x", SIZE_VALUES-6, "",
420 sim_io_printf (sd, "%*s0x%.4x", SIZE_VALUES-6, "",
421 (uint16_t)SEXT4(OP[i]));
425 sim_io_printf (sd, "%*s0x%.4x", SIZE_VALUES-6, "",
426 (uint16_t)SEXT3(OP[i]));
430 sim_io_printf (sd, "%*s0x%.4x", SIZE_VALUES-6, "",
432 sim_io_printf (sd, "%*s0x%.4x", SIZE_VALUES-6, "",
433 (uint16_t)GPR (OP[i + 1]));
440 sim_io_flush_stdout (sd);
444 do_trace_output_flush (SIM_DESC sd)
446 sim_io_flush_stdout (sd);
450 do_trace_output_finish (SIM_DESC sd)
453 " F0=%d F1=%d C=%d\n",
454 (State.trace.psw & PSR_F_BIT) != 0,
455 (State.trace.psw & PSR_F_BIT) != 0,
456 (State.trace.psw & PSR_C_BIT) != 0);
457 sim_io_flush_stdout (sd);
462 trace_output_40 (SIM_DESC sd, uint64_t val)
464 if ((cr16_debug & (DEBUG_TRACE | DEBUG_VALUES)) == (DEBUG_TRACE | DEBUG_VALUES))
467 " :: %*s0x%.2x%.8lx",
470 ((int)(val >> 32) & 0xff),
471 ((unsigned long) val) & 0xffffffff);
472 do_trace_output_finish ();
478 trace_output_32 (SIM_DESC sd, uint32_t val)
480 if ((cr16_debug & (DEBUG_TRACE | DEBUG_VALUES)) == (DEBUG_TRACE | DEBUG_VALUES))
487 do_trace_output_finish (sd);
492 trace_output_16 (SIM_DESC sd, uint16_t val)
494 if ((cr16_debug & (DEBUG_TRACE | DEBUG_VALUES)) == (DEBUG_TRACE | DEBUG_VALUES))
501 do_trace_output_finish (sd);
506 trace_output_void (SIM_DESC sd)
508 if ((cr16_debug & (DEBUG_TRACE | DEBUG_VALUES)) == (DEBUG_TRACE | DEBUG_VALUES))
510 sim_io_printf (sd, "\n");
511 do_trace_output_flush (sd);
516 trace_output_flag (SIM_DESC sd)
518 if ((cr16_debug & (DEBUG_TRACE | DEBUG_VALUES)) == (DEBUG_TRACE | DEBUG_VALUES))
524 do_trace_output_finish (sd);
532 #define trace_input(NAME, IN1, IN2, IN3)
533 #define trace_output(RESULT)
538 OP_2C_8 (SIM_DESC sd, SIM_CPU *cpu)
541 uint8_t a = OP[0] & 0xff;
542 uint16_t b = (GPR (OP[1])) & 0xff;
543 trace_input ("addub", OP_CONSTANT4_1, OP_REG, OP_VOID);
544 tmp = (a + b) & 0xff;
545 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
546 trace_output_16 (sd, tmp);
551 OP_2CB_C (SIM_DESC sd, SIM_CPU *cpu)
554 uint8_t a = ((OP[0]) & 0xff), b = (GPR (OP[1])) & 0xff;
555 trace_input ("addub", OP_CONSTANT16, OP_REG, OP_VOID);
556 tmp = (a + b) & 0xff;
557 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
558 trace_output_16 (sd, tmp);
563 OP_2D_8 (SIM_DESC sd, SIM_CPU *cpu)
565 uint8_t a = (GPR (OP[0])) & 0xff;
566 uint8_t b = (GPR (OP[1])) & 0xff;
567 uint16_t tmp = (a + b) & 0xff;
568 trace_input ("addub", OP_REG, OP_REG, OP_VOID);
569 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
570 trace_output_16 (sd, tmp);
575 OP_2E_8 (SIM_DESC sd, SIM_CPU *cpu)
578 uint16_t b = GPR (OP[1]);
579 uint16_t tmp = (a + b);
580 trace_input ("adduw", OP_CONSTANT4_1, OP_REG, OP_VOID);
581 SET_GPR (OP[1], tmp);
582 trace_output_16 (sd, tmp);
587 OP_2EB_C (SIM_DESC sd, SIM_CPU *cpu)
590 uint16_t b = GPR (OP[1]);
591 uint16_t tmp = (a + b);
592 trace_input ("adduw", OP_CONSTANT16, OP_REG, OP_VOID);
593 SET_GPR (OP[1], tmp);
594 trace_output_16 (sd, tmp);
599 OP_2F_8 (SIM_DESC sd, SIM_CPU *cpu)
601 uint16_t a = GPR (OP[0]);
602 uint16_t b = GPR (OP[1]);
603 uint16_t tmp = (a + b);
604 trace_input ("adduw", OP_REG, OP_REG, OP_VOID);
605 SET_GPR (OP[1], tmp);
606 trace_output_16 (sd, tmp);
611 OP_30_8 (SIM_DESC sd, SIM_CPU *cpu)
614 uint8_t b = (GPR (OP[1]) & 0xff);
615 uint16_t tmp = (a + b) & 0xff;
616 trace_input ("addb", OP_CONSTANT4_1, OP_REG, OP_VOID);
617 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
618 SET_PSR_C (tmp > 0xFF);
619 SET_PSR_F (((a & 0x80) == (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
620 trace_output_16 (sd, tmp);
625 OP_30B_C (SIM_DESC sd, SIM_CPU *cpu)
627 uint8_t a = (OP[0]) & 0xff;
628 uint8_t b = (GPR (OP[1]) & 0xff);
629 uint16_t tmp = (a + b) & 0xff;
630 trace_input ("addb", OP_CONSTANT16, OP_REG, OP_VOID);
631 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
632 SET_PSR_C (tmp > 0xFF);
633 SET_PSR_F (((a & 0x80) == (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
634 trace_output_16 (sd, tmp);
639 OP_31_8 (SIM_DESC sd, SIM_CPU *cpu)
641 uint8_t a = (GPR (OP[0]) & 0xff);
642 uint8_t b = (GPR (OP[1]) & 0xff);
643 uint16_t tmp = (a + b) & 0xff;
644 trace_input ("addb", OP_REG, OP_REG, OP_VOID);
645 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
646 SET_PSR_C (tmp > 0xFF);
647 SET_PSR_F (((a & 0x80) == (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
648 trace_output_16 (sd, tmp);
653 OP_32_8 (SIM_DESC sd, SIM_CPU *cpu)
656 uint16_t tmp, b = GPR (OP[1]);
658 trace_input ("addw", OP_CONSTANT4_1, OP_REG, OP_VOID);
659 SET_GPR (OP[1], tmp);
660 SET_PSR_C (tmp > 0xFFFF);
661 SET_PSR_F (((a & 0x8000) == (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
662 trace_output_16 (sd, tmp);
667 OP_32B_C (SIM_DESC sd, SIM_CPU *cpu)
670 uint16_t tmp, b = GPR (OP[1]);
672 trace_input ("addw", OP_CONSTANT16, OP_REG, OP_VOID);
673 SET_GPR (OP[1], tmp);
674 SET_PSR_C (tmp > 0xFFFF);
675 SET_PSR_F (((a & 0x8000) == (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
676 trace_output_16 (sd, tmp);
681 OP_33_8 (SIM_DESC sd, SIM_CPU *cpu)
683 uint16_t tmp, a = (GPR (OP[0])), b = (GPR (OP[1]));
684 trace_input ("addw", OP_REG, OP_REG, OP_VOID);
686 SET_GPR (OP[1], tmp);
687 SET_PSR_C (tmp > 0xFFFF);
688 SET_PSR_F (((a & 0x8000) == (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
689 trace_output_16 (sd, tmp);
694 OP_34_8 (SIM_DESC sd, SIM_CPU *cpu)
696 uint8_t tmp, a = OP[0] & 0xff, b = (GPR (OP[1])) & 0xff;
697 trace_input ("addcb", OP_CONSTANT4_1, OP_REG, OP_REG);
698 tmp = (a + b + PSR_C) & 0xff;
699 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
700 SET_PSR_C (tmp > 0xFF);
701 SET_PSR_F (((a & 0x80) == (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
702 trace_output_16 (sd, tmp);
707 OP_34B_C (SIM_DESC sd, SIM_CPU *cpu)
709 int8_t a = OP[0] & 0xff;
710 uint8_t b = (GPR (OP[1])) & 0xff;
711 uint8_t tmp = (a + b + PSR_C) & 0xff;
712 trace_input ("addcb", OP_CONSTANT16, OP_REG, OP_VOID);
713 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
714 SET_PSR_C (tmp > 0xFF);
715 SET_PSR_F (((a & 0x80) == (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
716 trace_output_16 (sd, tmp);
721 OP_35_8 (SIM_DESC sd, SIM_CPU *cpu)
723 uint8_t a = (GPR (OP[0])) & 0xff;
724 uint8_t b = (GPR (OP[1])) & 0xff;
725 uint8_t tmp = (a + b + PSR_C) & 0xff;
726 trace_input ("addcb", OP_REG, OP_REG, OP_VOID);
727 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
728 SET_PSR_C (tmp > 0xFF);
729 SET_PSR_F (((a & 0x80) == (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
730 trace_output_16 (sd, tmp);
735 OP_36_8 (SIM_DESC sd, SIM_CPU *cpu)
738 uint16_t b = GPR (OP[1]);
739 uint16_t tmp = (a + b + PSR_C);
740 trace_input ("addcw", OP_CONSTANT4_1, OP_REG, OP_VOID);
741 SET_GPR (OP[1], tmp);
742 SET_PSR_C (tmp > 0xFFFF);
743 SET_PSR_F (((a & 0x8000) == (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
744 trace_output_16 (sd, tmp);
749 OP_36B_C (SIM_DESC sd, SIM_CPU *cpu)
752 uint16_t b = GPR (OP[1]);
753 uint16_t tmp = (a + b + PSR_C);
754 trace_input ("addcw", OP_CONSTANT16, OP_REG, OP_VOID);
755 SET_GPR (OP[1], tmp);
756 SET_PSR_C (tmp > 0xFFFF);
757 SET_PSR_F (((a & 0x8000) == (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
758 trace_output_16 (sd, tmp);
763 OP_37_8 (SIM_DESC sd, SIM_CPU *cpu)
765 uint16_t a = GPR (OP[1]);
766 uint16_t b = GPR (OP[1]);
767 uint16_t tmp = (a + b + PSR_C);
768 trace_input ("addcw", OP_REG, OP_REG, OP_VOID);
769 SET_GPR (OP[1], tmp);
770 SET_PSR_C (tmp > 0xFFFF);
771 SET_PSR_F (((a & 0x8000) == (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
772 trace_output_16 (sd, tmp);
777 OP_60_8 (SIM_DESC sd, SIM_CPU *cpu)
780 uint32_t b = GPR32 (OP[1]);
781 uint32_t tmp = (a + b);
782 trace_input ("addd", OP_CONSTANT4_1, OP_REGP, OP_VOID);
783 SET_GPR32 (OP[1], tmp);
784 SET_PSR_C (tmp > 0xFFFFFFFF);
785 SET_PSR_F (((a & 0x80000000) == (b & 0x80000000)) && ((b & 0x80000000) != (tmp & 0x80000000)));
786 trace_output_32 (sd, tmp);
791 OP_60B_C (SIM_DESC sd, SIM_CPU *cpu)
793 int32_t a = (SEXT16(OP[0]));
794 uint32_t b = GPR32 (OP[1]);
795 uint32_t tmp = (a + b);
796 trace_input ("addd", OP_CONSTANT16, OP_REGP, OP_VOID);
797 SET_GPR32 (OP[1], tmp);
798 SET_PSR_C (tmp > 0xFFFFFFFF);
799 SET_PSR_F (((a & 0x80000000) == (b & 0x80000000)) && ((b & 0x80000000) != (tmp & 0x80000000)));
800 trace_output_32 (sd, tmp);
805 OP_61_8 (SIM_DESC sd, SIM_CPU *cpu)
807 uint32_t a = GPR32 (OP[0]);
808 uint32_t b = GPR32 (OP[1]);
809 uint32_t tmp = (a + b);
810 trace_input ("addd", OP_REGP, OP_REGP, OP_VOID);
811 SET_GPR32 (OP[1], tmp);
812 trace_output_32 (sd, tmp);
813 SET_PSR_C (tmp > 0xFFFFFFFF);
814 SET_PSR_F (((a & 0x80000000) == (b & 0x80000000)) && ((b & 0x80000000) != (tmp & 0x80000000)));
819 OP_4_8 (SIM_DESC sd, SIM_CPU *cpu)
822 uint32_t b = GPR32 (OP[1]);
824 trace_input ("addd", OP_CONSTANT20, OP_REGP, OP_VOID);
826 SET_GPR32 (OP[1], tmp);
827 SET_PSR_C (tmp > 0xFFFFFFFF);
828 SET_PSR_F (((a & 0x80000000) == (b & 0x80000000)) && ((b & 0x80000000) != (tmp & 0x80000000)));
829 trace_output_32 (sd, tmp);
834 OP_2_C (SIM_DESC sd, SIM_CPU *cpu)
837 uint32_t b = GPR32 (OP[1]);
839 trace_input ("addd", OP_CONSTANT32, OP_REGP, OP_VOID);
841 SET_GPR32 (OP[1], tmp);
842 SET_PSR_C (tmp > 0xFFFFFFFF);
843 SET_PSR_F (((a & 0x80000000) == (b & 0x80000000)) && ((b & 0x80000000) != (tmp & 0x80000000)));
844 trace_output_32 (sd, tmp);
849 OP_20_8 (SIM_DESC sd, SIM_CPU *cpu)
851 uint8_t tmp, a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
852 trace_input ("andb", OP_CONSTANT4, OP_REG, OP_VOID);
854 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
855 trace_output_16 (sd, tmp);
860 OP_20B_C (SIM_DESC sd, SIM_CPU *cpu)
862 uint8_t tmp, a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
863 trace_input ("andb", OP_CONSTANT16, OP_REG, OP_VOID);
865 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
866 trace_output_16 (sd, tmp);
871 OP_21_8 (SIM_DESC sd, SIM_CPU *cpu)
873 uint8_t tmp, a = (GPR (OP[0])) & 0xff, b = (GPR (OP[1])) & 0xff;
874 trace_input ("andb", OP_REG, OP_REG, OP_VOID);
876 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
877 trace_output_16 (sd, tmp);
882 OP_22_8 (SIM_DESC sd, SIM_CPU *cpu)
884 uint16_t tmp, a = OP[0], b = GPR (OP[1]);
885 trace_input ("andw", OP_CONSTANT4, OP_REG, OP_VOID);
887 SET_GPR (OP[1], tmp);
888 trace_output_16 (sd, tmp);
893 OP_22B_C (SIM_DESC sd, SIM_CPU *cpu)
895 uint16_t tmp, a = OP[0], b = GPR (OP[1]);
896 trace_input ("andw", OP_CONSTANT16, OP_REG, OP_VOID);
898 SET_GPR (OP[1], tmp);
899 trace_output_16 (sd, tmp);
904 OP_23_8 (SIM_DESC sd, SIM_CPU *cpu)
906 uint16_t tmp, a = GPR (OP[0]), b = GPR (OP[1]);
907 trace_input ("andw", OP_REG, OP_REG, OP_VOID);
909 SET_GPR (OP[1], tmp);
910 trace_output_16 (sd, tmp);
915 OP_4_C (SIM_DESC sd, SIM_CPU *cpu)
917 uint32_t tmp, a = OP[0], b = GPR32 (OP[1]);
918 trace_input ("andd", OP_CONSTANT32, OP_REGP, OP_VOID);
920 SET_GPR32 (OP[1], tmp);
921 trace_output_32 (sd, tmp);
926 OP_14B_14 (SIM_DESC sd, SIM_CPU *cpu)
928 uint32_t tmp, a = (GPR32 (OP[0])), b = (GPR32 (OP[1]));
929 trace_input ("andd", OP_REGP, OP_REGP, OP_VOID);
931 SET_GPR32 (OP[1], tmp);
932 trace_output_32 (sd, tmp);
937 OP_5_C (SIM_DESC sd, SIM_CPU *cpu)
939 uint32_t tmp, a = (OP[0]), b = GPR32 (OP[1]);
940 trace_input ("ord", OP_CONSTANT32, OP_REG, OP_VOID);
942 SET_GPR32 (OP[1], tmp);
943 trace_output_32 (sd, tmp);
948 OP_149_14 (SIM_DESC sd, SIM_CPU *cpu)
950 uint32_t tmp, a = GPR32 (OP[0]), b = GPR32 (OP[1]);
951 trace_input ("ord", OP_REGP, OP_REGP, OP_VOID);
953 SET_GPR32 (OP[1], tmp);
954 trace_output_32 (sd, tmp);
959 OP_6_C (SIM_DESC sd, SIM_CPU *cpu)
961 uint32_t tmp, a = (OP[0]), b = GPR32 (OP[1]);
962 trace_input ("xord", OP_CONSTANT32, OP_REG, OP_VOID);
964 SET_GPR32 (OP[1], tmp);
965 trace_output_32 (sd, tmp);
970 OP_14A_14 (SIM_DESC sd, SIM_CPU *cpu)
972 uint32_t tmp, a = GPR32 (OP[0]), b = GPR32 (OP[1]);
973 trace_input ("xord", OP_REGP, OP_REGP, OP_VOID);
975 SET_GPR32 (OP[1], tmp);
976 trace_output_32 (sd, tmp);
982 OP_1_4 (SIM_DESC sd, SIM_CPU *cpu)
984 uint32_t tmp = 0, cc = cond_stat (OP[0]);
985 trace_input ("b", OP_CONSTANT4, OP_DISPE9, OP_VOID);
989 tmp = (PC - (OP[1]));
991 tmp = (PC + (OP[1]));
992 /* If the resulting PC value is less than 0x00_0000 or greater
993 than 0xFF_FFFF, this instruction causes an IAD trap.*/
995 if ((tmp < 0x000000) || (tmp > 0xFFFFFF))
997 trace_output_void (sd);
998 EXCEPTION (SIM_SIGBUS);
1003 sign_flag = 0; /* Reset sign_flag. */
1004 trace_output_32 (sd, tmp);
1009 OP_18_8 (SIM_DESC sd, SIM_CPU *cpu)
1011 uint32_t tmp = 0, cc = cond_stat (OP[0]);
1012 trace_input ("b", OP_CONSTANT4, OP_DISP17, OP_VOID);
1019 /* If the resulting PC value is less than 0x00_0000 or greater
1020 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1022 if ((tmp < 0x000000) || (tmp > 0xFFFFFF))
1024 trace_output_void (sd);
1025 EXCEPTION (SIM_SIGBUS);
1030 sign_flag = 0; /* Reset sign_flag. */
1031 trace_output_32 (sd, tmp);
1036 OP_10_10 (SIM_DESC sd, SIM_CPU *cpu)
1038 uint32_t tmp = 0, cc = cond_stat (OP[0]);
1039 trace_input ("b", OP_CONSTANT4, OP_DISP25, OP_VOID);
1043 tmp = (PC - (OP[1]));
1045 tmp = (PC + (OP[1]));
1046 /* If the resulting PC value is less than 0x00_0000 or greater
1047 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1049 if ((tmp < 0x000000) || (tmp > 0xFFFFFF))
1051 trace_output_void (sd);
1052 EXCEPTION (SIM_SIGBUS);
1057 sign_flag = 0; /* Reset sign_flag. */
1058 trace_output_32 (sd, tmp);
1063 OP_C0_8 (SIM_DESC sd, SIM_CPU *cpu)
1066 trace_input ("bal", OP_REG, OP_DISP17, OP_VOID);
1067 tmp = ((PC + 4) >> 1); /* Store PC in RA register. */
1068 SET_GPR32 (14, tmp);
1070 tmp = (PC - (OP[1]));
1072 tmp = (PC + (OP[1]));
1074 /* If the resulting PC value is less than 0x00_0000 or greater
1075 than 0xFF_FFFF, this instruction causes an IAD trap. */
1077 if ((tmp < 0x000000) || (tmp > 0xFFFFFF))
1079 trace_output_void (sd);
1080 EXCEPTION (SIM_SIGBUS);
1084 sign_flag = 0; /* Reset sign_flag. */
1085 trace_output_32 (sd, tmp);
1091 OP_102_14 (SIM_DESC sd, SIM_CPU *cpu)
1094 trace_input ("bal", OP_REGP, OP_DISP25, OP_VOID);
1095 tmp = (((PC) + 4) >> 1); /* Store PC in reg pair. */
1096 SET_GPR32 (OP[0], tmp);
1098 tmp = ((PC) - (OP[1]));
1100 tmp = ((PC) + (OP[1]));
1101 /* If the resulting PC value is less than 0x00_0000 or greater
1102 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1104 if ((tmp < 0x000000) || (tmp > 0xFFFFFF))
1106 trace_output_void (sd);
1107 EXCEPTION (SIM_SIGBUS);
1111 sign_flag = 0; /* Reset sign_flag. */
1112 trace_output_32 (sd, tmp);
1117 OP_148_14 (SIM_DESC sd, SIM_CPU *cpu)
1120 trace_input ("jal", OP_REGP, OP_REGP, OP_VOID);
1121 SET_GPR32 (OP[0], (((PC) + 4) >> 1)); /* Store next PC in RA */
1122 tmp = GPR32 (OP[1]);
1123 tmp = SEXT24(tmp << 1);
1124 /* If the resulting PC value is less than 0x00_0000 or greater
1125 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1127 if ((tmp < 0x0) || (tmp > 0xFFFFFF))
1129 trace_output_void (sd);
1130 EXCEPTION (SIM_SIGBUS);
1135 trace_output_32 (sd, tmp);
1141 OP_D_C (SIM_DESC sd, SIM_CPU *cpu)
1144 trace_input ("jal", OP_REGP, OP_VOID, OP_VOID);
1145 SET_GPR32 (14, (((PC) + 2) >> 1)); /* Store next PC in RA */
1146 tmp = GPR32 (OP[0]);
1147 tmp = SEXT24(tmp << 1);
1148 /* If the resulting PC value is less than 0x00_0000 or greater
1149 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1151 if ((tmp < 0x0) || (tmp > 0xFFFFFF))
1153 trace_output_void (sd);
1154 EXCEPTION (SIM_SIGBUS);
1159 trace_output_32 (sd, tmp);
1165 OP_C_8 (SIM_DESC sd, SIM_CPU *cpu)
1168 uint8_t a = (GPR (OP[0]) & 0xFF);
1169 trace_input ("beq0b", OP_REG, OP_DISP5, OP_VOID);
1174 addr = (PC - OP[1]);
1176 addr = (PC + OP[1]);
1180 sign_flag = 0; /* Reset sign_flag. */
1181 trace_output_void (sd);
1186 OP_D_8 (SIM_DESC sd, SIM_CPU *cpu)
1189 uint8_t a = (GPR (OP[0]) & 0xFF);
1190 trace_input ("bne0b", OP_REG, OP_DISP5, OP_VOID);
1195 addr = (PC - OP[1]);
1197 addr = (PC + OP[1]);
1201 sign_flag = 0; /* Reset sign_flag. */
1202 trace_output_void (sd);
1207 OP_E_8 (SIM_DESC sd, SIM_CPU *cpu)
1210 uint16_t a = GPR (OP[0]);
1211 trace_input ("beq0w", OP_REG, OP_DISP5, OP_VOID);
1216 addr = (PC - OP[1]);
1218 addr = (PC + OP[1]);
1222 sign_flag = 0; /* Reset sign_flag. */
1223 trace_output_void (sd);
1228 OP_F_8 (SIM_DESC sd, SIM_CPU *cpu)
1231 uint16_t a = GPR (OP[0]);
1232 trace_input ("bne0w", OP_REG, OP_DISP5, OP_VOID);
1237 addr = (PC - OP[1]);
1239 addr = (PC + OP[1]);
1243 sign_flag = 0; /* Reset sign_flag. */
1244 trace_output_void (sd);
1250 OP_A0_C (SIM_DESC sd, SIM_CPU *cpu)
1253 trace_input ("jeq", OP_REGP, OP_VOID, OP_VOID);
1256 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits. */
1257 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit. */
1259 trace_output_32 (sd, tmp);
1264 OP_A1_C (SIM_DESC sd, SIM_CPU *cpu)
1267 trace_input ("jne", OP_REGP, OP_VOID, OP_VOID);
1270 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits. */
1271 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit. */
1273 trace_output_32 (sd, tmp);
1278 OP_A2_C (SIM_DESC sd, SIM_CPU *cpu)
1281 trace_input ("jcs", OP_REGP, OP_VOID, OP_VOID);
1284 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1285 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1287 trace_output_32 (sd, tmp);
1292 OP_A3_C (SIM_DESC sd, SIM_CPU *cpu)
1295 trace_input ("jcc", OP_REGP, OP_VOID, OP_VOID);
1298 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1299 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1301 trace_output_32 (sd, tmp);
1306 OP_A4_C (SIM_DESC sd, SIM_CPU *cpu)
1309 trace_input ("jhi", OP_REGP, OP_VOID, OP_VOID);
1312 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1313 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1315 trace_output_32 (sd, tmp);
1320 OP_A5_C (SIM_DESC sd, SIM_CPU *cpu)
1323 trace_input ("jls", OP_REGP, OP_VOID, OP_VOID);
1326 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1327 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1329 trace_output_32 (sd, tmp);
1334 OP_A6_C (SIM_DESC sd, SIM_CPU *cpu)
1337 trace_input ("jgt", OP_REGP, OP_VOID, OP_VOID);
1340 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1341 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1343 trace_output_32 (sd, tmp);
1348 OP_A7_C (SIM_DESC sd, SIM_CPU *cpu)
1351 trace_input ("jle", OP_REGP, OP_VOID, OP_VOID);
1354 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1355 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1357 trace_output_32 (sd, tmp);
1363 OP_A8_C (SIM_DESC sd, SIM_CPU *cpu)
1366 trace_input ("jfs", OP_REGP, OP_VOID, OP_VOID);
1369 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1370 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1372 trace_output_32 (sd, tmp);
1377 OP_A9_C (SIM_DESC sd, SIM_CPU *cpu)
1380 trace_input ("jfc", OP_REGP, OP_VOID, OP_VOID);
1383 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1384 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1386 trace_output_32 (sd, tmp);
1391 OP_AA_C (SIM_DESC sd, SIM_CPU *cpu)
1394 trace_input ("jlo", OP_REGP, OP_VOID, OP_VOID);
1395 if (((PSR_Z) == 0) & ((PSR_L) == 0))
1397 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1398 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1400 trace_output_32 (sd, tmp);
1405 OP_AB_C (SIM_DESC sd, SIM_CPU *cpu)
1408 trace_input ("jhs", OP_REGP, OP_VOID, OP_VOID);
1409 if (((PSR_Z) == 1) | ((PSR_L) == 1))
1411 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1412 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1414 trace_output_32 (sd, tmp);
1419 OP_AC_C (SIM_DESC sd, SIM_CPU *cpu)
1422 trace_input ("jlt", OP_REGP, OP_VOID, OP_VOID);
1423 if (((PSR_Z) == 0) & ((PSR_N) == 0))
1425 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1426 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1428 trace_output_32 (sd, tmp);
1433 OP_AD_C (SIM_DESC sd, SIM_CPU *cpu)
1436 trace_input ("jge", OP_REGP, OP_VOID, OP_VOID);
1437 if (((PSR_Z) == 1) | ((PSR_N) == 1))
1439 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1440 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1442 trace_output_32 (sd, tmp);
1447 OP_AE_C (SIM_DESC sd, SIM_CPU *cpu)
1450 trace_input ("jump", OP_REGP, OP_VOID, OP_VOID);
1451 tmp = GPR32 (OP[0]) /*& 0x3fffff*/; /* Use only 0 - 22 bits */
1452 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1453 trace_output_32 (sd, tmp);
1458 OP_AF_C (SIM_DESC sd, SIM_CPU *cpu)
1461 trace_input ("jusr", OP_REGP, OP_VOID, OP_VOID);
1462 tmp = (GPR32 (OP[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1463 JMP (tmp << 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1465 trace_output_32 (sd, tmp);
1470 OP_80_C (SIM_DESC sd, SIM_CPU *cpu)
1472 trace_input ("seq", OP_REG, OP_VOID, OP_VOID);
1477 trace_output_void (sd);
1481 OP_81_C (SIM_DESC sd, SIM_CPU *cpu)
1483 trace_input ("sne", OP_REG, OP_VOID, OP_VOID);
1488 trace_output_void (sd);
1493 OP_82_C (SIM_DESC sd, SIM_CPU *cpu)
1495 trace_input ("scs", OP_REG, OP_VOID, OP_VOID);
1500 trace_output_void (sd);
1505 OP_83_C (SIM_DESC sd, SIM_CPU *cpu)
1507 trace_input ("scc", OP_REG, OP_VOID, OP_VOID);
1512 trace_output_void (sd);
1517 OP_84_C (SIM_DESC sd, SIM_CPU *cpu)
1519 trace_input ("shi", OP_REG, OP_VOID, OP_VOID);
1524 trace_output_void (sd);
1529 OP_85_C (SIM_DESC sd, SIM_CPU *cpu)
1531 trace_input ("sls", OP_REG, OP_VOID, OP_VOID);
1536 trace_output_void (sd);
1541 OP_86_C (SIM_DESC sd, SIM_CPU *cpu)
1543 trace_input ("sgt", OP_REG, OP_VOID, OP_VOID);
1548 trace_output_void (sd);
1553 OP_87_C (SIM_DESC sd, SIM_CPU *cpu)
1555 trace_input ("sle", OP_REG, OP_VOID, OP_VOID);
1560 trace_output_void (sd);
1565 OP_88_C (SIM_DESC sd, SIM_CPU *cpu)
1567 trace_input ("sfs", OP_REG, OP_VOID, OP_VOID);
1572 trace_output_void (sd);
1577 OP_89_C (SIM_DESC sd, SIM_CPU *cpu)
1579 trace_input ("sfc", OP_REG, OP_VOID, OP_VOID);
1584 trace_output_void (sd);
1590 OP_8A_C (SIM_DESC sd, SIM_CPU *cpu)
1592 trace_input ("slo", OP_REG, OP_VOID, OP_VOID);
1593 if (((PSR_Z) == 0) & ((PSR_L) == 0))
1597 trace_output_void (sd);
1602 OP_8B_C (SIM_DESC sd, SIM_CPU *cpu)
1604 trace_input ("shs", OP_REG, OP_VOID, OP_VOID);
1605 if ( ((PSR_Z) == 1) | ((PSR_L) == 1))
1609 trace_output_void (sd);
1614 OP_8C_C (SIM_DESC sd, SIM_CPU *cpu)
1616 trace_input ("slt", OP_REG, OP_VOID, OP_VOID);
1617 if (((PSR_Z) == 0) & ((PSR_N) == 0))
1621 trace_output_void (sd);
1626 OP_8D_C (SIM_DESC sd, SIM_CPU *cpu)
1628 trace_input ("sge", OP_REG, OP_VOID, OP_VOID);
1629 if (((PSR_Z) == 1) | ((PSR_N) == 1))
1633 trace_output_void (sd);
1638 OP_D7_9 (SIM_DESC sd, SIM_CPU *cpu)
1640 uint8_t a = OP[0] & 0xff;
1641 uint32_t addr = OP[1], tmp;
1642 trace_input ("cbitb", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
1644 SET_PSR_F (tmp & (1 << a));
1645 tmp = tmp & ~(1 << a);
1647 trace_output_32 (sd, tmp);
1652 OP_107_14 (SIM_DESC sd, SIM_CPU *cpu)
1654 uint8_t a = OP[0] & 0xff;
1655 uint32_t addr = OP[1], tmp;
1656 trace_input ("cbitb", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
1658 SET_PSR_F (tmp & (1 << a));
1659 tmp = tmp & ~(1 << a);
1661 trace_output_32 (sd, tmp);
1666 OP_68_8 (SIM_DESC sd, SIM_CPU *cpu)
1668 uint8_t a = (OP[0]) & 0xff;
1669 uint32_t addr = (GPR (OP[2])) + OP[1], tmp;
1670 trace_input ("cbitb", OP_CONSTANT4, OP_R_INDEX7_ABS20, OP_VOID);
1672 SET_PSR_F (tmp & (1 << a));
1673 tmp = tmp & ~(1 << a);
1675 trace_output_32 (sd, addr);
1680 OP_1AA_A (SIM_DESC sd, SIM_CPU *cpu)
1682 uint8_t a = (OP[0]) & 0xff;
1683 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1684 trace_input ("cbitb", OP_CONSTANT4, OP_RP_INDEX_DISP14, OP_VOID);
1686 SET_PSR_F (tmp & (1 << a));
1687 tmp = tmp & ~(1 << a);
1689 trace_output_32 (sd, addr);
1694 OP_104_14 (SIM_DESC sd, SIM_CPU *cpu)
1696 uint8_t a = (OP[0]) & 0xff;
1697 uint32_t addr = (GPR (OP[2])) + OP[1], tmp;
1698 trace_input ("cbitb", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
1700 SET_PSR_F (tmp & (1 << a));
1701 tmp = tmp & ~(1 << a);
1703 trace_output_32 (sd, addr);
1708 OP_D4_9 (SIM_DESC sd, SIM_CPU *cpu)
1710 uint8_t a = (OP[0]) & 0xff;
1711 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1712 trace_input ("cbitb", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
1714 SET_PSR_F (tmp & (1 << a));
1715 tmp = tmp & ~(1 << a);
1717 trace_output_32 (sd, addr);
1722 OP_D6_9 (SIM_DESC sd, SIM_CPU *cpu)
1724 uint8_t a = (OP[0]) & 0xff;
1725 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1726 trace_input ("cbitb", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
1728 SET_PSR_F (tmp & (1 << a));
1729 tmp = tmp & ~(1 << a);
1731 trace_output_32 (sd, addr);
1737 OP_105_14 (SIM_DESC sd, SIM_CPU *cpu)
1739 uint8_t a = (OP[0]) & 0xff;
1740 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1741 trace_input ("cbitb", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
1743 SET_PSR_F (tmp & (1 << a));
1744 tmp = tmp & ~(1 << a);
1746 trace_output_32 (sd, addr);
1751 OP_106_14 (SIM_DESC sd, SIM_CPU *cpu)
1753 uint8_t a = (OP[0]) & 0xff;
1754 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1755 trace_input ("cbitb", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
1757 SET_PSR_F (tmp & (1 << a));
1758 tmp = tmp & ~(1 << a);
1760 trace_output_32 (sd, addr);
1766 OP_6F_8 (SIM_DESC sd, SIM_CPU *cpu)
1769 uint32_t addr = OP[1], tmp;
1770 trace_input ("cbitw", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
1772 SET_PSR_F (tmp & (1 << a));
1773 tmp = tmp & ~(1 << a);
1775 trace_output_32 (sd, tmp);
1780 OP_117_14 (SIM_DESC sd, SIM_CPU *cpu)
1783 uint32_t addr = OP[1], tmp;
1784 trace_input ("cbitw", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
1786 SET_PSR_F (tmp & (1 << a));
1787 tmp = tmp & ~(1 << a);
1789 trace_output_32 (sd, tmp);
1794 OP_36_7 (SIM_DESC sd, SIM_CPU *cpu)
1797 uint16_t a = (OP[0]), tmp;
1798 trace_input ("cbitw", OP_CONSTANT4, OP_R_INDEX8_ABS20, OP_VOID);
1801 addr = (GPR32 (12)) + OP[2];
1803 addr = (GPR32 (13)) + OP[2];
1806 SET_PSR_F (tmp & (1 << a));
1807 tmp = tmp & ~(1 << a);
1809 trace_output_32 (sd, addr);
1815 OP_1AB_A (SIM_DESC sd, SIM_CPU *cpu)
1817 uint16_t a = (OP[0]);
1818 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1819 trace_input ("cbitw", OP_CONSTANT4, OP_RP_INDEX_DISP14, OP_VOID);
1821 SET_PSR_F (tmp & (1 << a));
1822 tmp = tmp & ~(1 << a);
1824 trace_output_32 (sd, addr);
1829 OP_114_14 (SIM_DESC sd, SIM_CPU *cpu)
1831 uint16_t a = (OP[0]);
1832 uint32_t addr = (GPR (OP[2])) + OP[1], tmp;
1833 trace_input ("cbitw", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
1835 SET_PSR_F (tmp & (1 << a));
1836 tmp = tmp & ~(1 << a);
1838 trace_output_32 (sd, addr);
1844 OP_6E_8 (SIM_DESC sd, SIM_CPU *cpu)
1846 uint16_t a = (OP[0]);
1847 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1848 trace_input ("cbitw", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
1850 SET_PSR_F (tmp & (1 << a));
1851 tmp = tmp & ~(1 << a);
1853 trace_output_32 (sd, addr);
1858 OP_69_8 (SIM_DESC sd, SIM_CPU *cpu)
1860 uint16_t a = (OP[0]);
1861 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1862 trace_input ("cbitw", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
1864 SET_PSR_F (tmp & (1 << a));
1865 tmp = tmp & ~(1 << a);
1867 trace_output_32 (sd, addr);
1873 OP_115_14 (SIM_DESC sd, SIM_CPU *cpu)
1875 uint16_t a = (OP[0]);
1876 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1877 trace_input ("cbitw", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
1879 SET_PSR_F (tmp & (1 << a));
1880 tmp = tmp & ~(1 << a);
1882 trace_output_32 (sd, addr);
1887 OP_116_14 (SIM_DESC sd, SIM_CPU *cpu)
1889 uint16_t a = (OP[0]);
1890 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1891 trace_input ("cbitw", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
1893 SET_PSR_F (tmp & (1 << a));
1894 tmp = tmp & ~(1 << a);
1896 trace_output_32 (sd, addr);
1901 OP_E7_9 (SIM_DESC sd, SIM_CPU *cpu)
1903 uint8_t a = OP[0] & 0xff;
1904 uint32_t addr = OP[1], tmp;
1905 trace_input ("sbitb", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
1907 SET_PSR_F (tmp & (1 << a));
1908 tmp = tmp | (1 << a);
1910 trace_output_32 (sd, tmp);
1915 OP_10B_14 (SIM_DESC sd, SIM_CPU *cpu)
1917 uint8_t a = OP[0] & 0xff;
1918 uint32_t addr = OP[1], tmp;
1919 trace_input ("sbitb", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
1921 SET_PSR_F (tmp & (1 << a));
1922 tmp = tmp | (1 << a);
1924 trace_output_32 (sd, tmp);
1929 OP_70_8 (SIM_DESC sd, SIM_CPU *cpu)
1931 uint8_t a = OP[0] & 0xff;
1932 uint32_t addr = (GPR (OP[2])) + OP[1], tmp;
1933 trace_input ("sbitb", OP_CONSTANT4, OP_R_INDEX7_ABS20, OP_VOID);
1935 SET_PSR_F (tmp & (1 << a));
1936 tmp = tmp | (1 << a);
1938 trace_output_32 (sd, tmp);
1943 OP_1CA_A (SIM_DESC sd, SIM_CPU *cpu)
1945 uint8_t a = OP[0] & 0xff;
1946 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1947 trace_input ("sbitb", OP_CONSTANT4, OP_RP_INDEX_DISP14, OP_VOID);
1949 SET_PSR_F (tmp & (1 << a));
1950 tmp = tmp | (1 << a);
1952 trace_output_32 (sd, tmp);
1957 OP_108_14 (SIM_DESC sd, SIM_CPU *cpu)
1959 uint8_t a = OP[0] & 0xff;
1960 uint32_t addr = (GPR (OP[2])) + OP[1], tmp;
1961 trace_input ("sbitb", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
1963 SET_PSR_F (tmp & (1 << a));
1964 tmp = tmp | (1 << a);
1966 trace_output_32 (sd, tmp);
1972 OP_E4_9 (SIM_DESC sd, SIM_CPU *cpu)
1974 uint8_t a = OP[0] & 0xff;
1975 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1976 trace_input ("sbitb", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
1978 SET_PSR_F (tmp & (1 << a));
1979 tmp = tmp | (1 << a);
1981 trace_output_32 (sd, tmp);
1986 OP_E6_9 (SIM_DESC sd, SIM_CPU *cpu)
1988 uint8_t a = OP[0] & 0xff;
1989 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
1990 trace_input ("sbitb", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
1992 SET_PSR_F (tmp & (1 << a));
1993 tmp = tmp | (1 << a);
1995 trace_output_32 (sd, tmp);
2001 OP_109_14 (SIM_DESC sd, SIM_CPU *cpu)
2003 uint8_t a = OP[0] & 0xff;
2004 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2005 trace_input ("sbitb", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
2007 SET_PSR_F (tmp & (1 << a));
2008 tmp = tmp | (1 << a);
2010 trace_output_32 (sd, tmp);
2016 OP_10A_14 (SIM_DESC sd, SIM_CPU *cpu)
2018 uint8_t a = OP[0] & 0xff;
2019 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2020 trace_input ("sbitb", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
2022 SET_PSR_F (tmp & (1 << a));
2023 tmp = tmp | (1 << a);
2025 trace_output_32 (sd, tmp);
2031 OP_77_8 (SIM_DESC sd, SIM_CPU *cpu)
2034 uint32_t addr = OP[1], tmp;
2035 trace_input ("sbitw", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
2037 SET_PSR_F (tmp & (1 << a));
2038 tmp = tmp | (1 << a);
2040 trace_output_32 (sd, tmp);
2045 OP_11B_14 (SIM_DESC sd, SIM_CPU *cpu)
2048 uint32_t addr = OP[1], tmp;
2049 trace_input ("sbitw", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
2051 SET_PSR_F (tmp & (1 << a));
2052 tmp = tmp | (1 << a);
2054 trace_output_32 (sd, tmp);
2059 OP_3A_7 (SIM_DESC sd, SIM_CPU *cpu)
2062 uint16_t a = (OP[0]), tmp;
2063 trace_input ("sbitw", OP_CONSTANT4, OP_R_INDEX8_ABS20, OP_VOID);
2066 addr = (GPR32 (12)) + OP[2];
2068 addr = (GPR32 (13)) + OP[2];
2071 SET_PSR_F (tmp & (1 << a));
2072 tmp = tmp | (1 << a);
2074 trace_output_32 (sd, addr);
2079 OP_1CB_A (SIM_DESC sd, SIM_CPU *cpu)
2081 uint16_t a = (OP[0]);
2082 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2083 trace_input ("sbitw", OP_CONSTANT4, OP_RP_INDEX_DISP14, OP_VOID);
2085 SET_PSR_F (tmp & (1 << a));
2086 tmp = tmp | (1 << a);
2088 trace_output_32 (sd, addr);
2093 OP_118_14 (SIM_DESC sd, SIM_CPU *cpu)
2095 uint16_t a = (OP[0]);
2096 uint32_t addr = (GPR (OP[2])) + OP[1], tmp;
2097 trace_input ("sbitw", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
2099 SET_PSR_F (tmp & (1 << a));
2100 tmp = tmp | (1 << a);
2102 trace_output_32 (sd, addr);
2107 OP_76_8 (SIM_DESC sd, SIM_CPU *cpu)
2109 uint16_t a = (OP[0]);
2110 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2111 trace_input ("sbitw", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
2113 SET_PSR_F (tmp & (1 << a));
2114 tmp = tmp | (1 << a);
2116 trace_output_32 (sd, addr);
2121 OP_71_8 (SIM_DESC sd, SIM_CPU *cpu)
2123 uint16_t a = (OP[0]);
2124 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2125 trace_input ("sbitw", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
2127 SET_PSR_F (tmp & (1 << a));
2128 tmp = tmp | (1 << a);
2130 trace_output_32 (sd, addr);
2135 OP_119_14 (SIM_DESC sd, SIM_CPU *cpu)
2137 uint16_t a = (OP[0]);
2138 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2139 trace_input ("sbitw", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
2141 SET_PSR_F (tmp & (1 << a));
2142 tmp = tmp | (1 << a);
2144 trace_output_32 (sd, addr);
2149 OP_11A_14 (SIM_DESC sd, SIM_CPU *cpu)
2151 uint16_t a = (OP[0]);
2152 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2153 trace_input ("sbitw", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
2155 SET_PSR_F (tmp & (1 << a));
2156 tmp = tmp | (1 << a);
2158 trace_output_32 (sd, addr);
2164 OP_F7_9 (SIM_DESC sd, SIM_CPU *cpu)
2166 uint8_t a = OP[0] & 0xff;
2167 uint32_t addr = OP[1], tmp;
2168 trace_input ("tbitb", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
2170 SET_PSR_F (tmp & (1 << a));
2171 trace_output_32 (sd, tmp);
2176 OP_10F_14 (SIM_DESC sd, SIM_CPU *cpu)
2178 uint8_t a = OP[0] & 0xff;
2179 uint32_t addr = OP[1], tmp;
2180 trace_input ("tbitb", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
2182 SET_PSR_F (tmp & (1 << a));
2183 trace_output_32 (sd, tmp);
2188 OP_78_8 (SIM_DESC sd, SIM_CPU *cpu)
2190 uint8_t a = (OP[0]) & 0xff;
2191 uint32_t addr = (GPR (OP[2])) + OP[1], tmp;
2192 trace_input ("tbitb", OP_CONSTANT4, OP_R_INDEX7_ABS20, OP_VOID);
2194 SET_PSR_F (tmp & (1 << a));
2195 trace_output_32 (sd, addr);
2200 OP_1EA_A (SIM_DESC sd, SIM_CPU *cpu)
2202 uint8_t a = (OP[0]) & 0xff;
2203 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2204 trace_input ("tbitb", OP_CONSTANT4, OP_RP_INDEX_DISP14, OP_VOID);
2206 SET_PSR_F (tmp & (1 << a));
2207 trace_output_32 (sd, addr);
2212 OP_10C_14 (SIM_DESC sd, SIM_CPU *cpu)
2214 uint8_t a = (OP[0]) & 0xff;
2215 uint32_t addr = (GPR (OP[2])) + OP[1], tmp;
2216 trace_input ("tbitb", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
2218 SET_PSR_F (tmp & (1 << a));
2219 trace_output_32 (sd, addr);
2224 OP_F4_9 (SIM_DESC sd, SIM_CPU *cpu)
2226 uint8_t a = (OP[0]) & 0xff;
2227 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2228 trace_input ("tbitb", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
2230 SET_PSR_F (tmp & (1 << a));
2231 trace_output_32 (sd, addr);
2236 OP_F6_9 (SIM_DESC sd, SIM_CPU *cpu)
2238 uint8_t a = (OP[0]) & 0xff;
2239 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2240 trace_input ("tbitb", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
2242 SET_PSR_F (tmp & (1 << a));
2243 trace_output_32 (sd, addr);
2248 OP_10D_14 (SIM_DESC sd, SIM_CPU *cpu)
2250 uint8_t a = (OP[0]) & 0xff;
2251 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2252 trace_input ("tbitb", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
2254 SET_PSR_F (tmp & (1 << a));
2255 trace_output_32 (sd, addr);
2260 OP_10E_14 (SIM_DESC sd, SIM_CPU *cpu)
2262 uint8_t a = (OP[0]) & 0xff;
2263 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2264 trace_input ("tbitb", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
2266 SET_PSR_F (tmp & (1 << a));
2267 trace_output_32 (sd, addr);
2273 OP_7F_8 (SIM_DESC sd, SIM_CPU *cpu)
2276 uint32_t addr = OP[1], tmp;
2277 trace_input ("tbitw", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
2279 SET_PSR_F (tmp & (1 << a));
2280 trace_output_32 (sd, tmp);
2285 OP_11F_14 (SIM_DESC sd, SIM_CPU *cpu)
2288 uint32_t addr = OP[1], tmp;
2289 trace_input ("tbitw", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
2291 SET_PSR_F (tmp & (1 << a));
2292 trace_output_32 (sd, tmp);
2298 OP_3E_7 (SIM_DESC sd, SIM_CPU *cpu)
2301 uint16_t a = (OP[0]), tmp;
2302 trace_input ("tbitw", OP_CONSTANT4, OP_R_INDEX8_ABS20, OP_VOID);
2305 addr = (GPR32 (12)) + OP[2];
2307 addr = (GPR32 (13)) + OP[2];
2310 SET_PSR_F (tmp & (1 << a));
2311 trace_output_32 (sd, addr);
2316 OP_1EB_A (SIM_DESC sd, SIM_CPU *cpu)
2318 uint16_t a = (OP[0]);
2319 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2320 trace_input ("tbitw", OP_CONSTANT4, OP_RP_INDEX_DISP14, OP_VOID);
2322 SET_PSR_F (tmp & (1 << a));
2323 trace_output_32 (sd, addr);
2328 OP_11C_14 (SIM_DESC sd, SIM_CPU *cpu)
2330 uint16_t a = (OP[0]);
2331 uint32_t addr = (GPR (OP[2])) + OP[1], tmp;
2332 trace_input ("tbitw", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
2334 SET_PSR_F (tmp & (1 << a));
2335 trace_output_32 (sd, addr);
2340 OP_7E_8 (SIM_DESC sd, SIM_CPU *cpu)
2342 uint16_t a = (OP[0]);
2343 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2344 trace_input ("tbitw", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
2346 SET_PSR_F (tmp & (1 << a));
2347 trace_output_32 (sd, addr);
2352 OP_79_8 (SIM_DESC sd, SIM_CPU *cpu)
2354 uint16_t a = (OP[0]);
2355 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2356 trace_input ("tbitw", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
2358 SET_PSR_F (tmp & (1 << a));
2359 trace_output_32 (sd, addr);
2364 OP_11D_14 (SIM_DESC sd, SIM_CPU *cpu)
2366 uint16_t a = (OP[0]);
2367 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2368 trace_input ("tbitw", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
2370 SET_PSR_F (tmp & (1 << a));
2371 trace_output_32 (sd, addr);
2377 OP_11E_14 (SIM_DESC sd, SIM_CPU *cpu)
2379 uint16_t a = (OP[0]);
2380 uint32_t addr = (GPR32 (OP[2])) + OP[1], tmp;
2381 trace_input ("tbitw", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
2383 SET_PSR_F (tmp & (1 << a));
2384 trace_output_32 (sd, addr);
2390 OP_6_8 (SIM_DESC sd, SIM_CPU *cpu)
2393 uint16_t b = (GPR (OP[1]));
2394 trace_input ("tbit", OP_CONSTANT4, OP_REG, OP_VOID);
2395 SET_PSR_F (b & (1 << a));
2396 trace_output_16 (sd, b);
2401 OP_7_8 (SIM_DESC sd, SIM_CPU *cpu)
2403 uint16_t a = GPR (OP[0]);
2404 uint16_t b = (GPR (OP[1]));
2405 trace_input ("tbit", OP_REG, OP_REG, OP_VOID);
2406 SET_PSR_F (b & (1 << a));
2407 trace_output_16 (sd, b);
2413 OP_50_8 (SIM_DESC sd, SIM_CPU *cpu)
2415 uint8_t a = (OP[0]) & 0xFF;
2416 uint8_t b = (GPR (OP[1])) & 0xFF;
2417 trace_input ("cmpb", OP_CONSTANT4, OP_REG, OP_VOID);
2419 SET_PSR_N ((int8_t)a > (int8_t)b);
2421 trace_output_flag (sd);
2426 OP_50B_C (SIM_DESC sd, SIM_CPU *cpu)
2428 uint8_t a = (OP[0]) & 0xFF;
2429 uint8_t b = (GPR (OP[1])) & 0xFF;
2430 trace_input ("cmpb", OP_CONSTANT16, OP_REG, OP_VOID);
2432 SET_PSR_N ((int8_t)a > (int8_t)b);
2434 trace_output_flag (sd);
2439 OP_51_8 (SIM_DESC sd, SIM_CPU *cpu)
2441 uint8_t a = (GPR (OP[0])) & 0xFF;
2442 uint8_t b = (GPR (OP[1])) & 0xFF;
2443 trace_input ("cmpb", OP_REG, OP_REG, OP_VOID);
2445 SET_PSR_N ((int8_t)a > (int8_t)b);
2447 trace_output_flag (sd);
2452 OP_52_8 (SIM_DESC sd, SIM_CPU *cpu)
2454 uint16_t a = (OP[0]);
2455 uint16_t b = GPR (OP[1]);
2456 trace_input ("cmpw", OP_CONSTANT4, OP_REG, OP_VOID);
2458 SET_PSR_N ((int16_t)a > (int16_t)b);
2460 trace_output_flag (sd);
2465 OP_52B_C (SIM_DESC sd, SIM_CPU *cpu)
2467 uint16_t a = (OP[0]);
2468 uint16_t b = GPR (OP[1]);
2469 trace_input ("cmpw", OP_CONSTANT16, OP_REG, OP_VOID);
2471 SET_PSR_N ((int16_t)a > (int16_t)b);
2473 trace_output_flag (sd);
2478 OP_53_8 (SIM_DESC sd, SIM_CPU *cpu)
2480 uint16_t a = GPR (OP[0]) ;
2481 uint16_t b = GPR (OP[1]) ;
2482 trace_input ("cmpw", OP_REG, OP_REG, OP_VOID);
2484 SET_PSR_N ((int16_t)a > (int16_t)b);
2486 trace_output_flag (sd);
2491 OP_56_8 (SIM_DESC sd, SIM_CPU *cpu)
2493 uint32_t a = (OP[0]);
2494 uint32_t b = GPR32 (OP[1]);
2495 trace_input ("cmpd", OP_CONSTANT4, OP_REGP, OP_VOID);
2497 SET_PSR_N ((int32_t)a > (int32_t)b);
2499 trace_output_flag (sd);
2504 OP_56B_C (SIM_DESC sd, SIM_CPU *cpu)
2506 uint32_t a = (SEXT16(OP[0]));
2507 uint32_t b = GPR32 (OP[1]);
2508 trace_input ("cmpd", OP_CONSTANT16, OP_REGP, OP_VOID);
2510 SET_PSR_N ((int32_t)a > (int32_t)b);
2512 trace_output_flag (sd);
2517 OP_57_8 (SIM_DESC sd, SIM_CPU *cpu)
2519 uint32_t a = GPR32 (OP[0]) ;
2520 uint32_t b = GPR32 (OP[1]) ;
2521 trace_input ("cmpd", OP_REGP, OP_REGP, OP_VOID);
2523 SET_PSR_N ((int32_t)a > (int32_t)b);
2525 trace_output_flag (sd);
2530 OP_9_C (SIM_DESC sd, SIM_CPU *cpu)
2532 uint32_t a = (OP[0]);
2533 uint32_t b = GPR32 (OP[1]);
2534 trace_input ("cmpd", OP_CONSTANT32, OP_REGP, OP_VOID);
2536 SET_PSR_N ((int32_t)a > (int32_t)b);
2538 trace_output_flag (sd);
2544 OP_58_8 (SIM_DESC sd, SIM_CPU *cpu)
2546 uint8_t tmp = OP[0] & 0xFF;
2547 uint16_t a = (GPR (OP[1])) & 0xFF00;
2548 trace_input ("movb", OP_CONSTANT4, OP_REG, OP_VOID);
2549 SET_GPR (OP[1], (a | tmp));
2550 trace_output_16 (sd, tmp);
2555 OP_58B_C (SIM_DESC sd, SIM_CPU *cpu)
2557 uint8_t tmp = OP[0] & 0xFF;
2558 uint16_t a = (GPR (OP[1])) & 0xFF00;
2559 trace_input ("movb", OP_CONSTANT16, OP_REG, OP_VOID);
2560 SET_GPR (OP[1], (a | tmp));
2561 trace_output_16 (sd, tmp);
2566 OP_59_8 (SIM_DESC sd, SIM_CPU *cpu)
2568 uint8_t tmp = (GPR (OP[0])) & 0xFF;
2569 uint16_t a = (GPR (OP[1])) & 0xFF00;
2570 trace_input ("movb", OP_REG, OP_REG, OP_VOID);
2571 SET_GPR (OP[1], (a | tmp));
2572 trace_output_16 (sd, tmp);
2577 OP_5A_8 (SIM_DESC sd, SIM_CPU *cpu)
2579 uint16_t tmp = OP[0];
2580 trace_input ("movw", OP_CONSTANT4_1, OP_REG, OP_VOID);
2581 SET_GPR (OP[1], (tmp & 0xffff));
2582 trace_output_16 (sd, tmp);
2587 OP_5AB_C (SIM_DESC sd, SIM_CPU *cpu)
2589 int16_t tmp = OP[0];
2590 trace_input ("movw", OP_CONSTANT16, OP_REG, OP_VOID);
2591 SET_GPR (OP[1], (tmp & 0xffff));
2592 trace_output_16 (sd, tmp);
2597 OP_5B_8 (SIM_DESC sd, SIM_CPU *cpu)
2599 uint16_t tmp = GPR (OP[0]);
2600 uint32_t a = GPR32 (OP[1]);
2601 trace_input ("movw", OP_REG, OP_REGP, OP_VOID);
2602 a = (a & 0xffff0000) | tmp;
2603 SET_GPR32 (OP[1], a);
2604 trace_output_16 (sd, tmp);
2609 OP_5C_8 (SIM_DESC sd, SIM_CPU *cpu)
2611 uint8_t tmp = (GPR (OP[0])) & 0xFF;
2612 trace_input ("movxb", OP_REG, OP_REG, OP_VOID);
2613 SET_GPR (OP[1], ((SEXT8(tmp)) & 0xffff));
2614 trace_output_16 (sd, tmp);
2619 OP_5D_8 (SIM_DESC sd, SIM_CPU *cpu)
2621 uint8_t tmp = (GPR (OP[0])) & 0xFF;
2622 trace_input ("movzb", OP_REG, OP_REG, OP_VOID);
2623 SET_GPR (OP[1], tmp);
2624 trace_output_16 (sd, tmp);
2629 OP_5E_8 (SIM_DESC sd, SIM_CPU *cpu)
2631 uint16_t tmp = GPR (OP[0]);
2632 trace_input ("movxw", OP_REG, OP_REGP, OP_VOID);
2633 SET_GPR32 (OP[1], SEXT16(tmp));
2634 trace_output_16 (sd, tmp);
2639 OP_5F_8 (SIM_DESC sd, SIM_CPU *cpu)
2641 uint16_t tmp = GPR (OP[0]);
2642 trace_input ("movzw", OP_REG, OP_REGP, OP_VOID);
2643 SET_GPR32 (OP[1], (tmp & 0x0000FFFF));
2644 trace_output_16 (sd, tmp);
2649 OP_54_8 (SIM_DESC sd, SIM_CPU *cpu)
2651 int32_t tmp = OP[0];
2652 trace_input ("movd", OP_CONSTANT4, OP_REGP, OP_VOID);
2653 SET_GPR32 (OP[1], tmp);
2654 trace_output_32 (sd, tmp);
2659 OP_54B_C (SIM_DESC sd, SIM_CPU *cpu)
2661 int32_t tmp = SEXT16(OP[0]);
2662 trace_input ("movd", OP_CONSTANT16, OP_REGP, OP_VOID);
2663 SET_GPR32 (OP[1], tmp);
2664 trace_output_32 (sd, tmp);
2669 OP_55_8 (SIM_DESC sd, SIM_CPU *cpu)
2671 uint32_t tmp = GPR32 (OP[0]);
2672 trace_input ("movd", OP_REGP, OP_REGP, OP_VOID);
2673 SET_GPR32 (OP[1], tmp);
2674 trace_output_32 (sd, tmp);
2679 OP_5_8 (SIM_DESC sd, SIM_CPU *cpu)
2681 uint32_t tmp = OP[0];
2682 trace_input ("movd", OP_CONSTANT20, OP_REGP, OP_VOID);
2683 SET_GPR32 (OP[1], tmp);
2684 trace_output_32 (sd, tmp);
2689 OP_7_C (SIM_DESC sd, SIM_CPU *cpu)
2691 int32_t tmp = OP[0];
2692 trace_input ("movd", OP_CONSTANT32, OP_REGP, OP_VOID);
2693 SET_GPR32 (OP[1], tmp);
2694 trace_output_32 (sd, tmp);
2699 OP_14_D (SIM_DESC sd, SIM_CPU *cpu)
2701 uint32_t addr = GPR (0);
2702 uint16_t count = OP[0], reg = 2, tmp;
2703 trace_input ("loadm", OP_CONSTANT4, OP_VOID, OP_VOID);
2706 trace_output_void (sd);
2707 EXCEPTION (SIM_SIGBUS);
2717 if (reg == 6) reg = 8;
2721 trace_output_void (sd);
2727 OP_15_D (SIM_DESC sd, SIM_CPU *cpu)
2729 uint32_t addr = GPR32 (0);
2730 uint16_t count = OP[0], reg = 2, tmp;
2731 trace_input ("loadm", OP_CONSTANT4, OP_VOID, OP_VOID);
2734 trace_output_void (sd);
2735 EXCEPTION (SIM_SIGBUS);
2745 if (reg == 6) reg = 8;
2748 SET_GPR32 (0, addr);
2749 trace_output_void (sd);
2755 OP_88_8 (SIM_DESC sd, SIM_CPU *cpu)
2758 * ADDR = zext24(abs20) | remap (ie 0xF00000)
2761 * If (abs20 > 0xEFFFF) the resulting address is logically ORed
2762 * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
2763 * by the core to 16M-64k to 16M. */
2765 uint16_t tmp, a = (GPR (OP[1])) & 0xFF00;
2766 uint32_t addr = OP[0];
2767 trace_input ("loadb", OP_ABS20, OP_REG, OP_VOID);
2768 if (addr > 0xEFFFF) addr |= 0xF00000;
2770 SET_GPR (OP[1], (a | tmp));
2771 trace_output_16 (sd, tmp);
2776 OP_127_14 (SIM_DESC sd, SIM_CPU *cpu)
2782 uint16_t tmp, a = (GPR (OP[1])) & 0xFF00;
2783 uint32_t addr = OP[0];
2784 trace_input ("loadb", OP_ABS24, OP_REG, OP_VOID);
2786 SET_GPR (OP[1], (a | tmp));
2787 trace_output_16 (sd, tmp);
2792 OP_45_7 (SIM_DESC sd, SIM_CPU *cpu)
2794 /* loadb [Rindex]ABS20 REG
2795 * ADDR = Rindex + zext24(disp20)
2799 uint16_t tmp, a = (GPR (OP[2])) & 0xFF00;
2800 trace_input ("loadb", OP_R_INDEX8_ABS20, OP_REG, OP_VOID);
2803 addr = (GPR32 (12)) + OP[1];
2805 addr = (GPR32 (13)) + OP[1];
2808 SET_GPR (OP[2], (a | tmp));
2809 trace_output_16 (sd, tmp);
2815 OP_B_4 (SIM_DESC sd, SIM_CPU *cpu)
2817 /* loadb DIPS4(REGP) REG
2818 * ADDR = RPBASE + zext24(DISP4)
2820 uint16_t tmp, a = (GPR (OP[2])) & 0xFF00;
2821 uint32_t addr = (GPR32 (OP[1])) + OP[0];
2822 trace_input ("loadb", OP_RP_BASE_DISP4, OP_REG, OP_VOID);
2824 SET_GPR (OP[2], (a | tmp));
2825 trace_output_16 (sd, tmp);
2830 OP_BE_8 (SIM_DESC sd, SIM_CPU *cpu)
2832 /* loadb [Rindex]disp0(RPbasex) REG
2833 * ADDR = Rpbasex + Rindex
2837 uint16_t tmp, a = (GPR (OP[3])) & 0xFF00;
2838 trace_input ("loadb", OP_RP_INDEX_DISP0, OP_REG, OP_VOID);
2840 addr = (GPR32 (OP[2])) + OP[1];
2843 addr = (GPR32 (12)) + addr;
2845 addr = (GPR32 (13)) + addr;
2848 SET_GPR (OP[3], (a | tmp));
2849 trace_output_16 (sd, tmp);
2854 OP_219_A (SIM_DESC sd, SIM_CPU *cpu)
2856 /* loadb [Rindex]disp14(RPbasex) REG
2857 * ADDR = Rpbasex + Rindex + zext24(disp14)
2861 uint16_t tmp, a = (GPR (OP[3])) & 0xFF00;
2863 addr = (GPR32 (OP[2])) + OP[1];
2866 addr = (GPR32 (12)) + addr;
2868 addr = (GPR32 (13)) + addr;
2870 trace_input ("loadb", OP_RP_INDEX_DISP14, OP_REG, OP_VOID);
2872 SET_GPR (OP[3], (a | tmp));
2873 trace_output_16 (sd, tmp);
2879 OP_184_14 (SIM_DESC sd, SIM_CPU *cpu)
2881 /* loadb DISPE20(REG) REG
2882 * zext24(Rbase) + zext24(dispe20)
2885 uint16_t tmp,a = (GPR (OP[2])) & 0xFF00;
2886 uint32_t addr = OP[0] + (GPR (OP[1]));
2887 trace_input ("loadb", OP_R_BASE_DISPE20, OP_REG, OP_VOID);
2889 SET_GPR (OP[2], (a | tmp));
2890 trace_output_16 (sd, tmp);
2895 OP_124_14 (SIM_DESC sd, SIM_CPU *cpu)
2897 /* loadb DISP20(REG) REG
2898 * ADDR = zext24(Rbase) + zext24(disp20)
2901 uint16_t tmp,a = (GPR (OP[2])) & 0xFF00;
2902 uint32_t addr = OP[0] + (GPR (OP[1]));
2903 trace_input ("loadb", OP_R_BASE_DISP20, OP_REG, OP_VOID);
2905 SET_GPR (OP[2], (a | tmp));
2906 trace_output_16 (sd, tmp);
2911 OP_BF_8 (SIM_DESC sd, SIM_CPU *cpu)
2913 /* loadb disp16(REGP) REG
2914 * ADDR = RPbase + zext24(disp16)
2917 uint16_t tmp,a = (GPR (OP[2])) & 0xFF00;
2918 uint32_t addr = (GPR32 (OP[1])) + OP[0];
2919 trace_input ("loadb", OP_RP_BASE_DISP16, OP_REG, OP_VOID);
2921 SET_GPR (OP[2], (a | tmp));
2922 trace_output_16 (sd, tmp);
2927 OP_125_14 (SIM_DESC sd, SIM_CPU *cpu)
2929 /* loadb disp20(REGP) REG
2930 * ADDR = RPbase + zext24(disp20)
2932 uint16_t tmp,a = (GPR (OP[2])) & 0xFF00;
2933 uint32_t addr = (GPR32 (OP[1])) + OP[0];
2934 trace_input ("loadb", OP_RP_BASE_DISP20, OP_REG, OP_VOID);
2936 SET_GPR (OP[2], (a | tmp));
2937 trace_output_16 (sd, tmp);
2943 OP_185_14 (SIM_DESC sd, SIM_CPU *cpu)
2945 /* loadb -disp20(REGP) REG
2946 * ADDR = RPbase + zext24(-disp20)
2948 uint16_t tmp,a = (GPR (OP[2])) & 0xFF00;
2949 uint32_t addr = (GPR32 (OP[1])) + OP[1];
2950 trace_input ("loadb", OP_RP_BASE_DISPE20, OP_REG, OP_VOID);
2952 SET_GPR (OP[2], (a | tmp));
2953 trace_output_16 (sd, tmp);
2958 OP_126_14 (SIM_DESC sd, SIM_CPU *cpu)
2960 /* loadb [Rindex]disp20(RPbasexb) REG
2961 * ADDR = RPbasex + Rindex + zext24(disp20)
2965 uint16_t tmp, a = (GPR (OP[3])) & 0xFF00;
2966 trace_input ("loadb", OP_RP_INDEX_DISP20, OP_REG, OP_VOID);
2968 addr = (GPR32 (OP[2])) + OP[1];
2971 addr = (GPR32 (12)) + addr;
2973 addr = (GPR32 (13)) + addr;
2976 SET_GPR (OP[3], (a | tmp));
2977 trace_output_16 (sd, tmp);
2983 OP_89_8 (SIM_DESC sd, SIM_CPU *cpu)
2986 * ADDR = zext24(abs20) | remap
2989 * If (abs20 > 0xEFFFF) the resulting address is logically ORed
2990 * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
2991 * by the core to 16M-64k to 16M. */
2994 uint32_t addr = OP[0];
2995 trace_input ("loadw", OP_ABS20, OP_REG, OP_VOID);
2996 if (addr > 0xEFFFF) addr |= 0xF00000;
2998 SET_GPR (OP[1], tmp);
2999 trace_output_16 (sd, tmp);
3005 OP_12F_14 (SIM_DESC sd, SIM_CPU *cpu)
3011 uint32_t addr = OP[0];
3012 trace_input ("loadw", OP_ABS24, OP_REG, OP_VOID);
3014 SET_GPR (OP[1], tmp);
3015 trace_output_16 (sd, tmp);
3020 OP_47_7 (SIM_DESC sd, SIM_CPU *cpu)
3022 /* loadw [Rindex]ABS20 REG
3023 * ADDR = Rindex + zext24(disp20)
3028 trace_input ("loadw", OP_R_INDEX8_ABS20, OP_REG, OP_VOID);
3031 addr = (GPR32 (12)) + OP[1];
3033 addr = (GPR32 (13)) + OP[1];
3036 SET_GPR (OP[2], tmp);
3037 trace_output_16 (sd, tmp);
3043 OP_9_4 (SIM_DESC sd, SIM_CPU *cpu)
3045 /* loadw DIPS4(REGP) REGP
3046 * ADDR = RPBASE + zext24(DISP4)
3050 trace_input ("loadw", OP_RP_BASE_DISP4, OP_REG, OP_VOID);
3051 addr = (GPR32 (OP[1])) + OP[0];
3055 a = (GPR32 (OP[2])) & 0xffff0000;
3056 SET_GPR32 (OP[2], (a | tmp));
3059 SET_GPR (OP[2], tmp);
3061 trace_output_16 (sd, tmp);
3067 OP_9E_8 (SIM_DESC sd, SIM_CPU *cpu)
3069 /* loadw [Rindex]disp0(RPbasex) REG
3070 * ADDR = Rpbasex + Rindex
3075 trace_input ("loadw", OP_RP_INDEX_DISP0, OP_REG, OP_VOID);
3077 addr = (GPR32 (OP[2])) + OP[1];
3080 addr = (GPR32 (12)) + addr;
3082 addr = (GPR32 (13)) + addr;
3085 SET_GPR (OP[3], tmp);
3086 trace_output_16 (sd, tmp);
3092 OP_21B_A (SIM_DESC sd, SIM_CPU *cpu)
3094 /* loadw [Rindex]disp14(RPbasex) REG
3095 * ADDR = Rpbasex + Rindex + zext24(disp14)
3100 trace_input ("loadw", OP_RP_INDEX_DISP14, OP_REG, OP_VOID);
3101 addr = (GPR32 (OP[2])) + OP[1];
3104 addr = (GPR32 (12)) + addr;
3106 addr = (GPR32 (13)) + addr;
3109 SET_GPR (OP[3], tmp);
3110 trace_output_16 (sd, tmp);
3115 OP_18C_14 (SIM_DESC sd, SIM_CPU *cpu)
3117 /* loadw dispe20(REG) REGP
3118 * REGP = [DISPE20+[REG]] */
3122 trace_input ("loadw", OP_R_BASE_DISPE20, OP_REGP, OP_VOID);
3123 addr = OP[0] + (GPR (OP[1]));
3127 a = (GPR32 (OP[2])) & 0xffff0000;
3128 SET_GPR32 (OP[2], (a | tmp));
3131 SET_GPR (OP[2], tmp);
3133 trace_output_16 (sd, tmp);
3139 OP_12C_14 (SIM_DESC sd, SIM_CPU *cpu)
3141 /* loadw DISP20(REG) REGP
3142 * ADDR = zext24(Rbase) + zext24(disp20)
3147 trace_input ("loadw", OP_R_BASE_DISP20, OP_REGP, OP_VOID);
3148 addr = OP[0] + (GPR (OP[1]));
3152 a = (GPR32 (OP[2])) & 0xffff0000;
3153 SET_GPR32 (OP[2], (a | tmp));
3156 SET_GPR (OP[2], tmp);
3158 trace_output_16 (sd, tmp);
3163 OP_9F_8 (SIM_DESC sd, SIM_CPU *cpu)
3165 /* loadw disp16(REGP) REGP
3166 * ADDR = RPbase + zext24(disp16)
3170 trace_input ("loadw", OP_RP_BASE_DISP16, OP_REGP, OP_VOID);
3171 addr = (GPR32 (OP[1])) + OP[0];
3175 a = (GPR32 (OP[2])) & 0xffff0000;
3176 SET_GPR32 (OP[2], (a | tmp));
3179 SET_GPR (OP[2], tmp);
3181 trace_output_16 (sd, tmp);
3186 OP_12D_14 (SIM_DESC sd, SIM_CPU *cpu)
3188 /* loadw disp20(REGP) REGP
3189 * ADDR = RPbase + zext24(disp20)
3193 trace_input ("loadw", OP_RP_BASE_DISP20, OP_REG, OP_VOID);
3194 addr = (GPR32 (OP[1])) + OP[0];
3198 a = (GPR32 (OP[2])) & 0xffff0000;
3199 SET_GPR32 (OP[2], (a | tmp));
3202 SET_GPR (OP[2], tmp);
3204 trace_output_16 (sd, tmp);
3209 OP_18D_14 (SIM_DESC sd, SIM_CPU *cpu)
3211 /* loadw -disp20(REGP) REG
3212 * ADDR = RPbase + zext24(-disp20)
3217 trace_input ("loadw", OP_RP_BASE_DISPE20, OP_REG, OP_VOID);
3218 addr = (GPR32 (OP[1])) + OP[0];
3222 a = (GPR32 (OP[2])) & 0xffff0000;
3223 SET_GPR32 (OP[2], (a | tmp));
3226 SET_GPR (OP[2], tmp);
3228 trace_output_16 (sd, tmp);
3234 OP_12E_14 (SIM_DESC sd, SIM_CPU *cpu)
3236 /* loadw [Rindex]disp20(RPbasexb) REG
3237 * ADDR = RPbasex + Rindex + zext24(disp20)
3242 trace_input ("loadw", OP_RP_INDEX_DISP20, OP_REG, OP_VOID);
3245 addr = (GPR32 (12)) + OP[1] + (GPR32 (OP[2]));
3247 addr = (GPR32 (13)) + OP[1] + (GPR32 (OP[2]));
3250 SET_GPR (OP[3], tmp);
3251 trace_output_16 (sd, tmp);
3257 OP_87_8 (SIM_DESC sd, SIM_CPU *cpu)
3259 /* loadd ABS20, REGP
3260 * ADDR = zext24(abs20) | remap
3263 * If (abs20 > 0xEFFFF) the resulting address is logically ORed
3264 * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
3265 * by the core to 16M-64k to 16M. */
3269 trace_input ("loadd", OP_ABS20, OP_REGP, OP_VOID);
3270 if (addr > 0xEFFFF) addr |= 0xF00000;
3272 tmp = ((tmp << 16) & 0xffff)| ((tmp >> 16) & 0xffff);
3273 SET_GPR32 (OP[1], tmp);
3274 trace_output_32 (sd, tmp);
3279 OP_12B_14 (SIM_DESC sd, SIM_CPU *cpu)
3281 /* loadd ABS24, REGP
3285 uint32_t addr = OP[0];
3287 trace_input ("loadd", OP_ABS24, OP_REGP, OP_VOID);
3289 tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
3290 SET_GPR32 (OP[1],tmp);
3291 trace_output_32 (sd, tmp);
3297 OP_46_7 (SIM_DESC sd, SIM_CPU *cpu)
3299 /* loadd [Rindex]ABS20 REGP
3300 * ADDR = Rindex + zext24(disp20)
3304 trace_input ("loadd", OP_R_INDEX8_ABS20, OP_REGP, OP_VOID);
3307 addr = (GPR32 (12)) + OP[1];
3309 addr = (GPR32 (13)) + OP[1];
3312 tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
3313 SET_GPR32 (OP[2], tmp);
3314 trace_output_32 (sd, tmp);
3320 OP_A_4 (SIM_DESC sd, SIM_CPU *cpu)
3322 /* loadd dips4(regp) REGP
3323 * ADDR = Rpbase + zext24(disp4)
3326 uint32_t tmp, addr = (GPR32 (OP[1])) + OP[0];
3327 trace_input ("loadd", OP_RP_BASE_DISP4, OP_REGP, OP_VOID);
3329 tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
3330 SET_GPR32 (OP[2], tmp);
3331 trace_output_32 (sd, tmp);
3337 OP_AE_8 (SIM_DESC sd, SIM_CPU *cpu)
3339 /* loadd [Rindex]disp0(RPbasex) REGP
3340 * ADDR = Rpbasex + Rindex
3344 trace_input ("loadd", OP_RP_INDEX_DISP0, OP_REGP, OP_VOID);
3347 addr = (GPR32 (12)) + (GPR32 (OP[2])) + OP[1];
3349 addr = (GPR32 (13)) + (GPR32 (OP[2])) + OP[1];
3352 tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
3353 SET_GPR32 (OP[3], tmp);
3354 trace_output_32 (sd, tmp);
3360 OP_21A_A (SIM_DESC sd, SIM_CPU *cpu)
3362 /* loadd [Rindex]disp14(RPbasex) REGP
3363 * ADDR = Rpbasex + Rindex + zext24(disp14)
3367 trace_input ("loadd", OP_RP_INDEX_DISP14, OP_REGP, OP_VOID);
3370 addr = (GPR32 (12)) + OP[1] + (GPR32 (OP[2]));
3372 addr = (GPR32 (13)) + OP[1] + (GPR32 (OP[2]));
3375 tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
3376 SET_GPR (OP[3],tmp);
3377 trace_output_32 (sd, tmp);
3383 OP_188_14 (SIM_DESC sd, SIM_CPU *cpu)
3385 /* loadd dispe20(REG) REG
3386 * zext24(Rbase) + zext24(dispe20)
3389 uint32_t tmp, addr = OP[0] + (GPR (OP[1]));
3390 trace_input ("loadd", OP_R_BASE_DISPE20, OP_REGP, OP_VOID);
3392 tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
3393 SET_GPR32 (OP[2], tmp);
3394 trace_output_32 (sd, tmp);
3400 OP_128_14 (SIM_DESC sd, SIM_CPU *cpu)
3402 /* loadd DISP20(REG) REG
3403 * ADDR = zext24(Rbase) + zext24(disp20)
3406 uint32_t tmp, addr = OP[0] + (GPR (OP[1]));
3407 trace_input ("loadd", OP_R_BASE_DISP20, OP_REGP, OP_VOID);
3409 tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
3410 SET_GPR32 (OP[2], tmp);
3411 trace_output_32 (sd, tmp);
3416 OP_AF_8 (SIM_DESC sd, SIM_CPU *cpu)
3418 /* loadd disp16(REGP) REGP
3419 * ADDR = RPbase + zext24(disp16)
3421 uint32_t tmp, addr = OP[0] + (GPR32 (OP[1]));
3422 trace_input ("loadd", OP_RP_BASE_DISP16, OP_REGP, OP_VOID);
3424 tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
3425 SET_GPR32 (OP[2], tmp);
3426 trace_output_32 (sd, tmp);
3432 OP_129_14 (SIM_DESC sd, SIM_CPU *cpu)
3434 /* loadd disp20(REGP) REGP
3435 * ADDR = RPbase + zext24(disp20)
3437 uint32_t tmp, addr = OP[0] + (GPR32 (OP[1]));
3438 trace_input ("loadd", OP_RP_BASE_DISP20, OP_REGP, OP_VOID);
3440 tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
3441 SET_GPR32 (OP[2], tmp);
3442 trace_output_32 (sd, tmp);
3447 OP_189_14 (SIM_DESC sd, SIM_CPU *cpu)
3449 /* loadd -disp20(REGP) REGP
3450 * ADDR = RPbase + zext24(-disp20)
3453 uint32_t tmp, addr = OP[0] + (GPR32 (OP[1]));
3454 trace_input ("loadd", OP_RP_BASE_DISPE20, OP_REGP, OP_VOID);
3456 tmp = ((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff);
3457 SET_GPR32 (OP[2], tmp);
3458 trace_output_32 (sd, tmp);
3463 OP_12A_14 (SIM_DESC sd, SIM_CPU *cpu)
3465 /* loadd [Rindex]disp20(RPbasexb) REGP
3466 * ADDR = RPbasex + Rindex + zext24(disp20)
3470 trace_input ("loadd", OP_RP_INDEX_DISP20, OP_REGP, OP_VOID);
3473 addr = (GPR32 (12)) + OP[1] + (GPR32 (OP[2]));
3475 addr = (GPR32 (13)) + OP[1] + (GPR32 (OP[2]));
3478 tmp = ((tmp << 16) & 0xffff)| ((tmp >> 16) & 0xffff);
3479 SET_GPR32 (OP[3], tmp);
3480 trace_output_32 (sd, tmp);
3486 OP_C8_8 (SIM_DESC sd, SIM_CPU *cpu)
3489 * ADDR = zext24(abs20) | remap
3492 * If (abs20 > 0xEFFFF) the resulting address is logically ORed
3493 * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
3494 * by the core to 16M-64k to 16M. */
3496 uint8_t a = ((GPR (OP[0])) & 0xff);
3497 uint32_t addr = OP[1];
3498 trace_input ("storb", OP_REG, OP_ABS20_OUTPUT, OP_VOID);
3500 trace_output_32 (sd, addr);
3505 OP_137_14 (SIM_DESC sd, SIM_CPU *cpu)
3511 uint8_t a = ((GPR (OP[0])) & 0xff);
3512 uint32_t addr = OP[1];
3513 trace_input ("storb", OP_REG, OP_ABS24_OUTPUT, OP_VOID);
3515 trace_output_32 (sd, addr);
3520 OP_65_7 (SIM_DESC sd, SIM_CPU *cpu)
3522 /* storb REG, [Rindex]ABS20
3523 * ADDR = Rindex + zext24(disp20)
3527 uint8_t a = ((GPR (OP[0])) & 0xff);
3528 trace_input ("storb", OP_REG, OP_R_INDEX8_ABS20, OP_VOID);
3531 addr = (GPR32 (12)) + OP[2];
3533 addr = (GPR32 (13)) + OP[2];
3536 trace_output_32 (sd, addr);
3541 OP_F_4 (SIM_DESC sd, SIM_CPU *cpu)
3543 /* storb REG, DIPS4(REGP)
3544 * ADDR = RPBASE + zext24(DISP4)
3547 uint16_t a = ((GPR (OP[0])) & 0xff);
3548 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3549 trace_input ("storb", OP_REG, OP_RP_BASE_DISPE4, OP_VOID);
3551 trace_output_32 (sd, addr);
3556 OP_FE_8 (SIM_DESC sd, SIM_CPU *cpu)
3558 /* storb [Rindex]disp0(RPbasex) REG
3559 * ADDR = Rpbasex + Rindex
3563 uint8_t a = ((GPR (OP[0])) & 0xff);
3564 trace_input ("storb", OP_REG, OP_RP_INDEX_DISP0, OP_VOID);
3567 addr = (GPR32 (12)) + (GPR32 (OP[3])) + OP[2];
3569 addr = (GPR32 (13)) + (GPR32 (OP[3])) + OP[2];
3572 trace_output_32 (sd, addr);
3577 OP_319_A (SIM_DESC sd, SIM_CPU *cpu)
3579 /* storb REG, [Rindex]disp14(RPbasex)
3580 * ADDR = Rpbasex + Rindex + zext24(disp14)
3583 uint8_t a = ((GPR (OP[0])) & 0xff);
3584 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3585 trace_input ("storb", OP_REG, OP_RP_INDEX_DISP14, OP_VOID);
3587 trace_output_32 (sd, addr);
3592 OP_194_14 (SIM_DESC sd, SIM_CPU *cpu)
3594 /* storb REG, DISPE20(REG)
3595 * zext24(Rbase) + zext24(dispe20)
3598 uint8_t a = ((GPR (OP[0])) & 0xff);
3599 uint32_t addr = OP[1] + (GPR (OP[2]));
3600 trace_input ("storb", OP_REG, OP_R_BASE_DISPE20, OP_VOID);
3602 trace_output_32 (sd, addr);
3607 OP_134_14 (SIM_DESC sd, SIM_CPU *cpu)
3609 /* storb REG, DISP20(REG)
3610 * ADDR = zext24(Rbase) + zext24(disp20)
3613 uint8_t a = (GPR (OP[0]) & 0xff);
3614 uint32_t addr = OP[1] + (GPR (OP[2]));
3615 trace_input ("storb", OP_REG, OP_R_BASE_DISPS20, OP_VOID);
3617 trace_output_32 (sd, addr);
3622 OP_FF_8 (SIM_DESC sd, SIM_CPU *cpu)
3624 /* storb REG, disp16(REGP)
3625 * ADDR = RPbase + zext24(disp16)
3628 uint8_t a = ((GPR (OP[0])) & 0xff);
3629 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3630 trace_input ("storb", OP_REG, OP_RP_BASE_DISP16, OP_VOID);
3632 trace_output_32 (sd, addr);
3637 OP_135_14 (SIM_DESC sd, SIM_CPU *cpu)
3639 /* storb REG, disp20(REGP)
3640 * ADDR = RPbase + zext24(disp20)
3643 uint8_t a = ((GPR (OP[0])) & 0xff);
3644 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3645 trace_input ("storb", OP_REG, OP_RP_BASE_DISPS20, OP_VOID);
3647 trace_output_32 (sd, addr);
3652 OP_195_14 (SIM_DESC sd, SIM_CPU *cpu)
3654 /* storb REG, -disp20(REGP)
3655 * ADDR = RPbase + zext24(-disp20)
3658 uint8_t a = (GPR (OP[0]) & 0xff);
3659 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3660 trace_input ("storb", OP_REG, OP_RP_BASE_DISPE20, OP_VOID);
3662 trace_output_32 (sd, addr);
3667 OP_136_14 (SIM_DESC sd, SIM_CPU *cpu)
3669 /* storb REG, [Rindex]disp20(RPbase)
3670 * ADDR = RPbasex + Rindex + zext24(disp20)
3673 uint8_t a = (GPR (OP[0])) & 0xff;
3674 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3675 trace_input ("storb", OP_REG, OP_RP_INDEX_DISPS20, OP_VOID);
3677 trace_output_32 (sd, addr);
3680 /* STR_IMM instructions. */
3683 OP_81_8 (SIM_DESC sd, SIM_CPU *cpu)
3685 uint8_t a = (OP[0]) & 0xff;
3686 uint32_t addr = OP[1];
3687 trace_input ("storb", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
3689 trace_output_32 (sd, addr);
3694 OP_123_14 (SIM_DESC sd, SIM_CPU *cpu)
3696 uint8_t a = (OP[0]) & 0xff;
3697 uint32_t addr = OP[1];
3698 trace_input ("storb", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
3700 trace_output_32 (sd, addr);
3705 OP_42_7 (SIM_DESC sd, SIM_CPU *cpu)
3708 uint8_t a = (OP[0]) & 0xff;
3709 trace_input ("storb", OP_CONSTANT4, OP_R_INDEX8_ABS20, OP_VOID);
3712 addr = (GPR32 (12)) + OP[2];
3714 addr = (GPR32 (13)) + OP[2];
3717 trace_output_32 (sd, addr);
3722 OP_218_A (SIM_DESC sd, SIM_CPU *cpu)
3724 uint8_t a = (OP[0]) & 0xff;
3725 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3726 trace_input ("storb", OP_CONSTANT4, OP_RP_BASE_DISP14, OP_VOID);
3728 trace_output_32 (sd, addr);
3733 OP_82_8 (SIM_DESC sd, SIM_CPU *cpu)
3735 uint8_t a = (OP[0]) & 0xff;
3736 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3737 trace_input ("storb", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
3739 trace_output_32 (sd, addr);
3744 OP_120_14 (SIM_DESC sd, SIM_CPU *cpu)
3746 uint8_t a = (OP[0]) & 0xff;
3747 uint32_t addr = (GPR (OP[2])) + OP[1];
3748 trace_input ("storb", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
3750 trace_output_32 (sd, addr);
3755 OP_83_8 (SIM_DESC sd, SIM_CPU *cpu)
3757 uint8_t a = (OP[0]) & 0xff;
3758 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3759 trace_input ("storb", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
3761 trace_output_32 (sd, addr);
3766 OP_121_14 (SIM_DESC sd, SIM_CPU *cpu)
3768 uint8_t a = (OP[0]) & 0xff;
3769 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3770 trace_input ("storb", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
3772 trace_output_32 (sd, addr);
3777 OP_122_14 (SIM_DESC sd, SIM_CPU *cpu)
3779 uint8_t a = (OP[0]) & 0xff;
3780 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3781 trace_input ("storb", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
3783 trace_output_32 (sd, addr);
3785 /* endif for STR_IMM. */
3789 OP_C9_8 (SIM_DESC sd, SIM_CPU *cpu)
3791 uint16_t a = GPR (OP[0]);
3792 uint32_t addr = OP[1];
3793 trace_input ("storw", OP_REG, OP_ABS20_OUTPUT, OP_VOID);
3795 trace_output_32 (sd, addr);
3800 OP_13F_14 (SIM_DESC sd, SIM_CPU *cpu)
3802 uint16_t a = GPR (OP[0]);
3803 uint32_t addr = OP[1];
3804 trace_input ("storw", OP_REG, OP_ABS24_OUTPUT, OP_VOID);
3806 trace_output_32 (sd, addr);
3811 OP_67_7 (SIM_DESC sd, SIM_CPU *cpu)
3814 uint16_t a = GPR (OP[0]);
3815 trace_input ("storw", OP_REG, OP_R_INDEX8_ABS20, OP_VOID);
3818 addr = (GPR32 (12)) + OP[2];
3820 addr = (GPR32 (13)) + OP[2];
3823 trace_output_32 (sd, addr);
3829 OP_D_4 (SIM_DESC sd, SIM_CPU *cpu)
3831 uint16_t a = (GPR (OP[0]));
3832 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3833 trace_input ("storw", OP_REGP, OP_RP_BASE_DISPE4, OP_VOID);
3835 trace_output_32 (sd, addr);
3840 OP_DE_8 (SIM_DESC sd, SIM_CPU *cpu)
3842 uint16_t a = GPR (OP[0]);
3843 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3844 trace_input ("storw", OP_REG, OP_RP_INDEX_DISP0, OP_VOID);
3846 trace_output_32 (sd, addr);
3851 OP_31B_A (SIM_DESC sd, SIM_CPU *cpu)
3853 uint16_t a = GPR (OP[0]);
3854 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3855 trace_input ("storw", OP_REG, OP_RP_INDEX_DISP14, OP_VOID);
3857 trace_output_32 (sd, addr);
3862 OP_19C_14 (SIM_DESC sd, SIM_CPU *cpu)
3864 uint16_t a = (GPR (OP[0]));
3865 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3866 trace_input ("storw", OP_REGP, OP_RP_BASE_DISPE20, OP_VOID);
3868 trace_output_32 (sd, addr);
3873 OP_13C_14 (SIM_DESC sd, SIM_CPU *cpu)
3875 uint16_t a = (GPR (OP[0]));
3876 uint32_t addr = (GPR (OP[2])) + OP[1];
3877 trace_input ("storw", OP_REG, OP_R_BASE_DISPS20, OP_VOID);
3879 trace_output_32 (sd, addr);
3884 OP_DF_8 (SIM_DESC sd, SIM_CPU *cpu)
3886 uint16_t a = (GPR (OP[0]));
3887 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3888 trace_input ("storw", OP_REG, OP_RP_BASE_DISP16, OP_VOID);
3890 trace_output_32 (sd, addr);
3895 OP_13D_14 (SIM_DESC sd, SIM_CPU *cpu)
3897 uint16_t a = (GPR (OP[0]));
3898 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3899 trace_input ("storw", OP_REG, OP_RP_BASE_DISPS20, OP_VOID);
3901 trace_output_32 (sd, addr);
3906 OP_19D_14 (SIM_DESC sd, SIM_CPU *cpu)
3908 uint16_t a = (GPR (OP[0]));
3909 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3910 trace_input ("storw", OP_REG, OP_RP_BASE_DISPE20, OP_VOID);
3912 trace_output_32 (sd, addr);
3917 OP_13E_14 (SIM_DESC sd, SIM_CPU *cpu)
3919 uint16_t a = (GPR (OP[0]));
3920 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3921 trace_input ("storw", OP_REG, OP_RP_INDEX_DISPS20, OP_VOID);
3923 trace_output_32 (sd, addr);
3926 /* STORE-w IMM instruction *****/
3929 OP_C1_8 (SIM_DESC sd, SIM_CPU *cpu)
3932 uint32_t addr = OP[1];
3933 trace_input ("storw", OP_CONSTANT4, OP_ABS20_OUTPUT, OP_VOID);
3935 trace_output_32 (sd, addr);
3940 OP_133_14 (SIM_DESC sd, SIM_CPU *cpu)
3943 uint32_t addr = OP[1];
3944 trace_input ("storw", OP_CONSTANT4, OP_ABS24_OUTPUT, OP_VOID);
3946 trace_output_32 (sd, addr);
3951 OP_62_7 (SIM_DESC sd, SIM_CPU *cpu)
3955 trace_input ("storw", OP_CONSTANT4, OP_R_INDEX8_ABS20, OP_VOID);
3958 addr = (GPR32 (12)) + OP[2];
3960 addr = (GPR32 (13)) + OP[2];
3963 trace_output_32 (sd, addr);
3968 OP_318_A (SIM_DESC sd, SIM_CPU *cpu)
3971 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3972 trace_input ("storw", OP_CONSTANT4, OP_RP_BASE_DISP14, OP_VOID);
3974 trace_output_32 (sd, addr);
3979 OP_C2_8 (SIM_DESC sd, SIM_CPU *cpu)
3982 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3983 trace_input ("storw", OP_CONSTANT4, OP_RP_INDEX_DISP0, OP_VOID);
3985 trace_output_32 (sd, addr);
3990 OP_130_14 (SIM_DESC sd, SIM_CPU *cpu)
3993 uint32_t addr = (GPR32 (OP[2])) + OP[1];
3994 trace_input ("storw", OP_CONSTANT4, OP_R_BASE_DISPS20, OP_VOID);
3996 trace_output_32 (sd, addr);
4001 OP_C3_8 (SIM_DESC sd, SIM_CPU *cpu)
4004 uint32_t addr = (GPR32 (OP[2])) + OP[1];
4005 trace_input ("storw", OP_CONSTANT4, OP_RP_BASE_DISP16, OP_VOID);
4007 trace_output_32 (sd, addr);
4013 OP_131_14 (SIM_DESC sd, SIM_CPU *cpu)
4016 uint32_t addr = (GPR32 (OP[2])) + OP[1];
4017 trace_input ("storw", OP_CONSTANT4, OP_RP_BASE_DISPS20, OP_VOID);
4019 trace_output_32 (sd, addr);
4024 OP_132_14 (SIM_DESC sd, SIM_CPU *cpu)
4027 uint32_t addr = (GPR32 (OP[2])) + OP[1];
4028 trace_input ("storw", OP_CONSTANT4, OP_RP_INDEX_DISPS20, OP_VOID);
4030 trace_output_32 (sd, addr);
4036 OP_C7_8 (SIM_DESC sd, SIM_CPU *cpu)
4038 uint32_t a = GPR32 (OP[0]);
4039 uint32_t addr = OP[1];
4040 trace_input ("stord", OP_REGP, OP_ABS20_OUTPUT, OP_VOID);
4042 trace_output_32 (sd, addr);
4047 OP_13B_14 (SIM_DESC sd, SIM_CPU *cpu)
4049 uint32_t a = GPR32 (OP[0]);
4050 uint32_t addr = OP[1];
4051 trace_input ("stord", OP_REGP, OP_ABS24_OUTPUT, OP_VOID);
4053 trace_output_32 (sd, addr);
4058 OP_66_7 (SIM_DESC sd, SIM_CPU *cpu)
4060 uint32_t addr, a = GPR32 (OP[0]);
4061 trace_input ("stord", OP_REGP, OP_R_INDEX8_ABS20, OP_VOID);
4064 addr = (GPR32 (12)) + OP[2];
4066 addr = (GPR32 (13)) + OP[2];
4069 trace_output_32 (sd, addr);
4074 OP_E_4 (SIM_DESC sd, SIM_CPU *cpu)
4076 uint32_t a = GPR32 (OP[0]);
4077 uint32_t addr = (GPR32 (OP[2])) + OP[1];
4078 trace_input ("stord", OP_REGP, OP_RP_BASE_DISPE4, OP_VOID);
4080 trace_output_32 (sd, addr);
4085 OP_EE_8 (SIM_DESC sd, SIM_CPU *cpu)
4087 uint32_t a = GPR32 (OP[0]);
4088 uint32_t addr = (GPR32 (OP[2])) + OP[1];
4089 trace_input ("stord", OP_REGP, OP_RP_INDEX_DISP0, OP_VOID);
4091 trace_output_32 (sd, addr);
4096 OP_31A_A (SIM_DESC sd, SIM_CPU *cpu)
4098 uint32_t a = GPR32 (OP[0]);
4099 uint32_t addr = (GPR32 (OP[2])) + OP[1];
4100 trace_input ("stord", OP_REGP, OP_RP_INDEX_DISP14, OP_VOID);
4102 trace_output_32 (sd, addr);
4107 OP_198_14 (SIM_DESC sd, SIM_CPU *cpu)
4109 uint32_t a = GPR32 (OP[0]);
4110 uint32_t addr = (GPR32 (OP[2])) + OP[1];
4111 trace_input ("stord", OP_REGP, OP_R_BASE_DISPE20, OP_VOID);
4113 trace_output_32 (sd, addr);
4118 OP_138_14 (SIM_DESC sd, SIM_CPU *cpu)
4120 uint32_t a = GPR32 (OP[0]);
4121 uint32_t addr = (GPR32 (OP[2])) + OP[1];
4122 trace_input ("stord", OP_REGP, OP_R_BASE_DISPS20, OP_VOID);
4124 trace_output_32 (sd, addr);
4129 OP_EF_8 (SIM_DESC sd, SIM_CPU *cpu)
4131 uint32_t a = GPR32 (OP[0]);
4132 uint32_t addr = (GPR32 (OP[2])) + OP[1];
4133 trace_input ("stord", OP_REGP, OP_RP_BASE_DISP16, OP_VOID);
4135 trace_output_32 (sd, addr);
4140 OP_139_14 (SIM_DESC sd, SIM_CPU *cpu)
4142 uint32_t a = GPR32 (OP[0]);
4143 uint32_t addr = (GPR32 (OP[2])) + OP[1];
4144 trace_input ("stord", OP_REGP, OP_RP_BASE_DISPS20, OP_VOID);
4146 trace_output_32 (sd, addr);
4151 OP_199_14 (SIM_DESC sd, SIM_CPU *cpu)
4153 uint32_t a = GPR32 (OP[0]);
4154 uint32_t addr = (GPR32 (OP[2])) + OP[1];
4155 trace_input ("stord", OP_REGP, OP_RP_BASE_DISPE20, OP_VOID);
4157 trace_output_32 (sd, addr);
4162 OP_13A_14 (SIM_DESC sd, SIM_CPU *cpu)
4164 uint32_t a = GPR32 (OP[0]);
4165 uint32_t addr = (GPR32 (OP[2])) + OP[1];
4166 trace_input ("stord", OP_REGP, OP_RP_INDEX_DISPS20, OP_VOID);
4168 trace_output_32 (sd, addr);
4173 OP_14D_14 (SIM_DESC sd, SIM_CPU *cpu)
4177 trace_input ("macuw", OP_REG, OP_REG, OP_REGP);
4181 /*REVISIT FOR SATURATION and Q FORMAT. */
4182 SET_GPR32 (OP[2], tmp);
4183 trace_output_32 (sd, tmp);
4188 OP_14E_14 (SIM_DESC sd, SIM_CPU *cpu)
4191 uint16_t src1, src2;
4192 trace_input ("macuw", OP_REG, OP_REG, OP_REGP);
4196 /*REVISIT FOR SATURATION. */
4197 SET_GPR32 (OP[2], tmp);
4198 trace_output_32 (sd, tmp);
4203 OP_14F_14 (SIM_DESC sd, SIM_CPU *cpu)
4207 trace_input ("macsw", OP_REG, OP_REG, OP_REGP);
4211 /*REVISIT FOR SATURATION. */
4212 SET_GPR32 (OP[2], tmp);
4213 trace_output_32 (sd, tmp);
4219 OP_64_8 (SIM_DESC sd, SIM_CPU *cpu)
4222 int8_t a = (OP[0]) & 0xff;
4223 int8_t b = (GPR (OP[1])) & 0xff;
4224 trace_input ("mulb", OP_CONSTANT4_1, OP_REG, OP_VOID);
4225 tmp = (a * b) & 0xff;
4226 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
4227 trace_output_16 (sd, tmp);
4232 OP_64B_C (SIM_DESC sd, SIM_CPU *cpu)
4235 int8_t a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
4236 trace_input ("mulb", OP_CONSTANT4, OP_REG, OP_VOID);
4237 tmp = (a * b) & 0xff;
4238 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
4239 trace_output_16 (sd, tmp);
4245 OP_65_8 (SIM_DESC sd, SIM_CPU *cpu)
4248 int8_t a = (GPR (OP[0])) & 0xff, b = (GPR (OP[1])) & 0xff;
4249 trace_input ("mulb", OP_REG, OP_REG, OP_VOID);
4250 tmp = (a * b) & 0xff;
4251 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
4252 trace_output_16 (sd, tmp);
4258 OP_66_8 (SIM_DESC sd, SIM_CPU *cpu)
4262 int16_t b = (GPR (OP[1]));
4263 trace_input ("mulw", OP_CONSTANT4_1, OP_REG, OP_VOID);
4264 tmp = (a * b) & 0xffff;
4265 SET_GPR (OP[1], tmp);
4266 trace_output_32 (sd, tmp);
4271 OP_66B_C (SIM_DESC sd, SIM_CPU *cpu)
4274 int16_t a = OP[0], b = (GPR (OP[1]));
4275 trace_input ("mulw", OP_CONSTANT4, OP_REG, OP_VOID);
4276 tmp = (a * b) & 0xffff;
4277 SET_GPR (OP[1], tmp);
4278 trace_output_32 (sd, tmp);
4284 OP_67_8 (SIM_DESC sd, SIM_CPU *cpu)
4287 int16_t a = (GPR (OP[0])), b = (GPR (OP[1]));
4288 trace_input ("mulw", OP_REG, OP_REG, OP_VOID);
4289 tmp = (a * b) & 0xffff;
4290 SET_GPR (OP[1], tmp);
4291 trace_output_32 (sd, tmp);
4297 OP_B_8 (SIM_DESC sd, SIM_CPU *cpu)
4300 int8_t a = (GPR (OP[0])) & 0xff, b = (GPR (OP[1])) & 0xff;
4301 trace_input ("mulsb", OP_REG, OP_REG, OP_VOID);
4303 SET_GPR (OP[1], tmp);
4304 trace_output_32 (sd, tmp);
4309 OP_62_8 (SIM_DESC sd, SIM_CPU *cpu)
4312 int16_t a = (GPR (OP[0])), b = (GPR (OP[1]));
4313 trace_input ("mulsw", OP_REG, OP_REGP, OP_VOID);
4315 SET_GPR32 (OP[1], tmp);
4316 trace_output_32 (sd, tmp);
4321 OP_63_8 (SIM_DESC sd, SIM_CPU *cpu)
4324 uint16_t a = (GPR (OP[0])), b = (GPR (OP[1]));
4325 trace_input ("muluw", OP_REG, OP_REGP, OP_VOID);
4327 SET_GPR32 (OP[1], tmp);
4328 trace_output_32 (sd, tmp);
4334 OP_2C00_10 (SIM_DESC sd, SIM_CPU *cpu)
4336 trace_input ("nop", OP_VOID, OP_VOID, OP_VOID);
4339 ins_type_counters[ (int)State.ins_type ]--; /* don't count nops as normal instructions */
4340 switch (State.ins_type)
4343 ins_type_counters[ (int)INS_UNKNOWN ]++;
4347 EXCEPTION (SIM_SIGTRAP);
4349 trace_output_void (sd);
4355 OP_24_8 (SIM_DESC sd, SIM_CPU *cpu)
4357 uint8_t tmp, a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
4358 trace_input ("orb", OP_CONSTANT4, OP_REG, OP_VOID);
4360 SET_GPR (OP[1], ((GPR (OP[1]) | tmp)));
4361 trace_output_16 (sd, tmp);
4366 OP_24B_C (SIM_DESC sd, SIM_CPU *cpu)
4368 uint8_t tmp, a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
4369 trace_input ("orb", OP_CONSTANT16, OP_REG, OP_VOID);
4371 SET_GPR (OP[1], ((GPR (OP[1]) | tmp)));
4372 trace_output_16 (sd, tmp);
4377 OP_25_8 (SIM_DESC sd, SIM_CPU *cpu)
4379 uint8_t tmp, a = (GPR (OP[0])) & 0xff, b = (GPR (OP[1])) & 0xff;
4380 trace_input ("orb", OP_REG, OP_REG, OP_VOID);
4382 SET_GPR (OP[1], ((GPR (OP[1]) | tmp)));
4383 trace_output_16 (sd, tmp);
4388 OP_26_8 (SIM_DESC sd, SIM_CPU *cpu)
4390 uint16_t tmp, a = (OP[0]), b = (GPR (OP[1]));
4391 trace_input ("orw", OP_CONSTANT4, OP_REG, OP_VOID);
4393 SET_GPR (OP[1], tmp);
4394 trace_output_16 (sd, tmp);
4400 OP_26B_C (SIM_DESC sd, SIM_CPU *cpu)
4402 uint16_t tmp, a = (OP[0]), b = (GPR (OP[1]));
4403 trace_input ("orw", OP_CONSTANT16, OP_REG, OP_VOID);
4405 SET_GPR (OP[1], tmp);
4406 trace_output_16 (sd, tmp);
4411 OP_27_8 (SIM_DESC sd, SIM_CPU *cpu)
4413 uint16_t tmp, a = (GPR (OP[0])), b = (GPR (OP[1]));
4414 trace_input ("orw", OP_REG, OP_REG, OP_VOID);
4416 SET_GPR (OP[1], tmp);
4417 trace_output_16 (sd, tmp);
4423 OP_13_9 (SIM_DESC sd, SIM_CPU *cpu)
4426 uint16_t tmp, b = (GPR (OP[1])) & 0xFF;
4427 trace_input ("lshb", OP_CONSTANT4, OP_REG, OP_VOID);
4428 /* A positive count specifies a shift to the left;
4429 * A negative count specifies a shift to the right. */
4435 sign_flag = 0; /* Reset sign_flag. */
4437 SET_GPR (OP[1], ((tmp & 0xFF) | ((GPR (OP[1])) & 0xFF00)));
4438 trace_output_16 (sd, tmp);
4443 OP_44_8 (SIM_DESC sd, SIM_CPU *cpu)
4445 uint16_t a = (GPR (OP[0])) & 0xff;
4446 uint16_t tmp, b = (GPR (OP[1])) & 0xFF;
4447 trace_input ("lshb", OP_REG, OP_REG, OP_VOID);
4448 if (a & ((long)1 << 3))
4453 a = (unsigned int) (a & 0x7);
4455 /* A positive count specifies a shift to the left;
4456 * A negative count specifies a shift to the right. */
4462 sign_flag = 0; /* Reset sign_flag. */
4463 SET_GPR (OP[1], ((tmp & 0xFF) | ((GPR (OP[1])) & 0xFF00)));
4464 trace_output_16 (sd, tmp);
4469 OP_46_8 (SIM_DESC sd, SIM_CPU *cpu)
4471 uint16_t tmp, b = GPR (OP[1]);
4472 int16_t a = GPR (OP[0]);
4473 trace_input ("lshw", OP_REG, OP_REG, OP_VOID);
4474 if (a & ((long)1 << 4))
4479 a = (unsigned int) (a & 0xf);
4481 /* A positive count specifies a shift to the left;
4482 * A negative count specifies a shift to the right. */
4488 sign_flag = 0; /* Reset sign_flag. */
4489 SET_GPR (OP[1], (tmp & 0xffff));
4490 trace_output_16 (sd, tmp);
4495 OP_49_8 (SIM_DESC sd, SIM_CPU *cpu)
4497 uint16_t tmp, b = GPR (OP[1]);
4499 trace_input ("lshw", OP_CONSTANT5, OP_REG, OP_VOID);
4500 /* A positive count specifies a shift to the left;
4501 * A negative count specifies a shift to the right. */
4507 sign_flag = 0; /* Reset sign_flag. */
4508 SET_GPR (OP[1], (tmp & 0xffff));
4509 trace_output_16 (sd, tmp);
4514 OP_25_7 (SIM_DESC sd, SIM_CPU *cpu)
4516 uint32_t tmp, b = GPR32 (OP[1]);
4518 trace_input ("lshd", OP_CONSTANT6, OP_REGP, OP_VOID);
4519 /* A positive count specifies a shift to the left;
4520 * A negative count specifies a shift to the right. */
4526 sign_flag = 0; /* Reset sign flag. */
4528 SET_GPR32 (OP[1], tmp);
4529 trace_output_32 (sd, tmp);
4534 OP_47_8 (SIM_DESC sd, SIM_CPU *cpu)
4536 uint32_t tmp, b = GPR32 (OP[1]);
4537 uint16_t a = GPR (OP[0]);
4538 trace_input ("lshd", OP_REG, OP_REGP, OP_VOID);
4539 if (a & ((long)1 << 5))
4544 a = (unsigned int) (a & 0x1f);
4545 /* A positive count specifies a shift to the left;
4546 * A negative count specifies a shift to the right. */
4552 sign_flag = 0; /* Reset sign flag. */
4554 SET_GPR32 (OP[1], tmp);
4555 trace_output_32 (sd, tmp);
4560 OP_80_9 (SIM_DESC sd, SIM_CPU *cpu)
4563 int8_t tmp, b = (GPR (OP[1])) & 0xFF;
4564 trace_input ("ashub", OP_CONSTANT4, OP_REG, OP_VOID);
4565 /* A positive count specifies a shift to the left;
4566 * A negative count specifies a shift to the right. */
4572 sign_flag = 0; /* Reset sign flag. */
4574 SET_GPR (OP[1], ((tmp & 0xFF) | ((GPR (OP[1])) & 0xff00)));
4575 trace_output_16 (sd, tmp);
4580 OP_81_9 (SIM_DESC sd, SIM_CPU *cpu)
4583 int8_t tmp, b = (GPR (OP[1])) & 0xFF;
4584 trace_input ("ashub", OP_CONSTANT4, OP_REG, OP_VOID);
4585 /* A positive count specifies a shift to the left;
4586 * A negative count specifies a shift to the right. */
4592 sign_flag = 0; /* Reset sign flag. */
4594 SET_GPR (OP[1], ((tmp & 0xFF) | ((GPR (OP[1])) & 0xFF00)));
4595 trace_output_16 (sd, tmp);
4601 OP_41_8 (SIM_DESC sd, SIM_CPU *cpu)
4603 int16_t a = (GPR (OP[0]));
4604 int8_t tmp, b = (GPR (OP[1])) & 0xFF;
4605 trace_input ("ashub", OP_REG, OP_REG, OP_VOID);
4607 if (a & ((long)1 << 3))
4612 a = (unsigned int) (a & 0x7);
4614 /* A positive count specifies a shift to the left;
4615 * A negative count specifies a shift to the right. */
4621 sign_flag = 0; /* Reset sign flag. */
4623 SET_GPR (OP[1], ((tmp & 0xFF) | ((GPR (OP[1])) & 0xFF00)));
4624 trace_output_16 (sd, tmp);
4630 OP_42_8 (SIM_DESC sd, SIM_CPU *cpu)
4632 int16_t tmp, b = GPR (OP[1]);
4634 trace_input ("ashuw", OP_CONSTANT5, OP_REG, OP_VOID);
4635 /* A positive count specifies a shift to the left;
4636 * A negative count specifies a shift to the right. */
4642 sign_flag = 0; /* Reset sign flag. */
4644 SET_GPR (OP[1], (tmp & 0xffff));
4645 trace_output_16 (sd, tmp);
4650 OP_43_8 (SIM_DESC sd, SIM_CPU *cpu)
4652 int16_t tmp, b = GPR (OP[1]);
4654 trace_input ("ashuw", OP_CONSTANT5, OP_REG, OP_VOID);
4655 /* A positive count specifies a shift to the left;
4656 * A negative count specifies a shift to the right. */
4662 sign_flag = 0; /* Reset sign flag. */
4663 SET_GPR (OP[1], (tmp & 0xffff));
4664 trace_output_16 (sd, tmp);
4669 OP_45_8 (SIM_DESC sd, SIM_CPU *cpu)
4672 int16_t a = GPR (OP[0]), b = GPR (OP[1]);
4673 trace_input ("ashuw", OP_REG, OP_REG, OP_VOID);
4675 if (a & ((long)1 << 4))
4680 a = (unsigned int) (a & 0xf);
4681 /* A positive count specifies a shift to the left;
4682 * A negative count specifies a shift to the right. */
4689 sign_flag = 0; /* Reset sign flag. */
4690 SET_GPR (OP[1], (tmp & 0xffff));
4691 trace_output_16 (sd, tmp);
4696 OP_26_7 (SIM_DESC sd, SIM_CPU *cpu)
4698 int32_t tmp,b = GPR32 (OP[1]);
4700 trace_input ("ashud", OP_CONSTANT6, OP_REGP, OP_VOID);
4701 /* A positive count specifies a shift to the left;
4702 * A negative count specifies a shift to the right. */
4708 sign_flag = 0; /* Reset sign flag. */
4709 SET_GPR32 (OP[1], tmp);
4710 trace_output_32 (sd, tmp);
4715 OP_27_7 (SIM_DESC sd, SIM_CPU *cpu)
4718 int32_t a = OP[0], b = GPR32 (OP[1]);
4719 trace_input ("ashud", OP_CONSTANT6, OP_REGP, OP_VOID);
4720 /* A positive count specifies a shift to the left;
4721 * A negative count specifies a shift to the right. */
4727 sign_flag = 0; /* Reset sign flag. */
4728 SET_GPR32 (OP[1], tmp);
4729 trace_output_32 (sd, tmp);
4734 OP_48_8 (SIM_DESC sd, SIM_CPU *cpu)
4737 int32_t a = GPR32 (OP[0]), b = GPR32 (OP[1]);
4738 trace_input ("ashud", OP_REGP, OP_REGP, OP_VOID);
4740 if (a & ((long)1 << 5))
4745 a = (unsigned int) (a & 0x1f);
4746 /* A positive count specifies a shift to the left;
4747 * A negative count specifies a shift to the right. */
4753 sign_flag = 0; /* Reset sign flag. */
4754 SET_GPR32 (OP[1], tmp);
4755 trace_output_32 (sd, tmp);
4761 OP_16_D (SIM_DESC sd, SIM_CPU *cpu)
4763 uint32_t addr = GPR (1);
4764 uint16_t count = OP[0], reg = 2;
4765 trace_input ("storm", OP_CONSTANT4, OP_VOID, OP_VOID);
4768 trace_output_void (sd);
4769 EXCEPTION (SIM_SIGBUS);
4774 SW (addr, (GPR (reg)));
4778 if (reg == 6) reg = 8;
4783 trace_output_void (sd);
4789 OP_17_D (SIM_DESC sd, SIM_CPU *cpu)
4791 uint32_t addr = GPR32 (6);
4792 uint16_t count = OP[0], reg = 2;
4793 trace_input ("stormp", OP_CONSTANT4, OP_VOID, OP_VOID);
4796 trace_output_void (sd);
4797 EXCEPTION (SIM_SIGBUS);
4802 SW (addr, (GPR (reg)));
4806 if (reg == 6) reg = 8;
4809 SET_GPR32 (6, addr);
4810 trace_output_void (sd);
4815 OP_38_8 (SIM_DESC sd, SIM_CPU *cpu)
4818 uint8_t b = (GPR (OP[1])) & 0xff;
4819 uint16_t tmp = (~a + 1 + b) & 0xff;
4820 trace_input ("subb", OP_CONSTANT4, OP_REG, OP_VOID);
4821 /* see ../common/sim-alu.h for a more extensive discussion on how to
4822 compute the carry/overflow bits. */
4823 SET_PSR_C (tmp > 0xff);
4824 SET_PSR_F (((a & 0x80) != (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
4825 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
4826 trace_output_16 (sd, tmp);
4831 OP_38B_C (SIM_DESC sd, SIM_CPU *cpu)
4833 uint8_t a = OP[0] & 0xFF;
4834 uint8_t b = (GPR (OP[1])) & 0xFF;
4835 uint16_t tmp = (~a + 1 + b) & 0xFF;
4836 trace_input ("subb", OP_CONSTANT16, OP_REG, OP_VOID);
4837 /* see ../common/sim-alu.h for a more extensive discussion on how to
4838 compute the carry/overflow bits. */
4839 SET_PSR_C (tmp > 0xff);
4840 SET_PSR_F (((a & 0x80) != (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
4841 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
4842 trace_output_16 (sd, tmp);
4847 OP_39_8 (SIM_DESC sd, SIM_CPU *cpu)
4849 uint8_t a = (GPR (OP[0])) & 0xFF;
4850 uint8_t b = (GPR (OP[1])) & 0xFF;
4851 uint16_t tmp = (~a + 1 + b) & 0xff;
4852 trace_input ("subb", OP_REG, OP_REG, OP_VOID);
4853 /* see ../common/sim-alu.h for a more extensive discussion on how to
4854 compute the carry/overflow bits. */
4855 SET_PSR_C (tmp > 0xff);
4856 SET_PSR_F (((a & 0x80) != (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
4857 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
4858 trace_output_16 (sd, tmp);
4863 OP_3A_8 (SIM_DESC sd, SIM_CPU *cpu)
4866 uint16_t b = GPR (OP[1]);
4867 uint16_t tmp = (~a + 1 + b);
4868 trace_input ("subw", OP_CONSTANT4, OP_REG, OP_VOID);
4869 /* see ../common/sim-alu.h for a more extensive discussion on how to
4870 compute the carry/overflow bits. */
4871 SET_PSR_C (tmp > 0xffff);
4872 SET_PSR_F (((a & 0x8000) != (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
4873 SET_GPR (OP[1], tmp);
4874 trace_output_16 (sd, tmp);
4879 OP_3AB_C (SIM_DESC sd, SIM_CPU *cpu)
4882 uint16_t b = GPR (OP[1]);
4883 uint32_t tmp = (~a + 1 + b);
4884 trace_input ("subw", OP_CONSTANT16, OP_REG, OP_VOID);
4885 /* see ../common/sim-alu.h for a more extensive discussion on how to
4886 compute the carry/overflow bits. */
4887 SET_PSR_C (tmp > 0xffff);
4888 SET_PSR_F (((a & 0x8000) != (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
4889 SET_GPR (OP[1], tmp & 0xffff);
4890 trace_output_16 (sd, tmp);
4895 OP_3B_8 (SIM_DESC sd, SIM_CPU *cpu)
4897 uint16_t a = GPR (OP[0]);
4898 uint16_t b = GPR (OP[1]);
4899 uint32_t tmp = (~a + 1 + b);
4900 trace_input ("subw", OP_REG, OP_REG, OP_VOID);
4901 /* see ../common/sim-alu.h for a more extensive discussion on how to
4902 compute the carry/overflow bits. */
4903 SET_PSR_C (tmp > 0xffff);
4904 SET_PSR_F (((a & 0x8000) != (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
4905 SET_GPR (OP[1], tmp & 0xffff);
4906 trace_output_16 (sd, tmp);
4911 OP_3C_8 (SIM_DESC sd, SIM_CPU *cpu)
4914 uint8_t b = (GPR (OP[1])) & 0xff;
4915 //uint16_t tmp1 = a + 1;
4916 uint16_t tmp1 = a + (PSR_C);
4917 uint16_t tmp = (~tmp1 + 1 + b);
4918 trace_input ("subcb", OP_CONSTANT4, OP_REG, OP_VOID);
4919 /* see ../common/sim-alu.h for a more extensive discussion on how to
4920 compute the carry/overflow bits. */
4921 SET_PSR_C (tmp > 0xff);
4922 SET_PSR_F (((a & 0x80) != (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
4923 SET_GPR (OP[1], tmp);
4924 trace_output_16 (sd, tmp);
4929 OP_3CB_C (SIM_DESC sd, SIM_CPU *cpu)
4932 uint16_t b = (GPR (OP[1])) & 0xff;
4933 //uint16_t tmp1 = a + 1;
4934 uint16_t tmp1 = a + (PSR_C);
4935 uint16_t tmp = (~tmp1 + 1 + b);
4936 trace_input ("subcb", OP_CONSTANT16, OP_REG, OP_VOID);
4937 /* see ../common/sim-alu.h for a more extensive discussion on how to
4938 compute the carry/overflow bits. */
4939 SET_PSR_C (tmp > 0xff);
4940 SET_PSR_F (((a & 0x80) != (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
4941 SET_GPR (OP[1], tmp);
4942 trace_output_16 (sd, tmp);
4947 OP_3D_8 (SIM_DESC sd, SIM_CPU *cpu)
4949 uint16_t a = (GPR (OP[0])) & 0xff;
4950 uint16_t b = (GPR (OP[1])) & 0xff;
4951 uint16_t tmp1 = a + (PSR_C);
4952 uint16_t tmp = (~tmp1 + 1 + b);
4953 trace_input ("subcb", OP_REG, OP_REG, OP_VOID);
4954 /* see ../common/sim-alu.h for a more extensive discussion on how to
4955 compute the carry/overflow bits. */
4956 SET_PSR_C (tmp > 0xff);
4957 SET_PSR_F (((a & 0x80) != (b & 0x80)) && ((b & 0x80) != (tmp & 0x80)));
4958 SET_GPR (OP[1], tmp);
4959 trace_output_16 (sd, tmp);
4964 OP_3E_8 (SIM_DESC sd, SIM_CPU *cpu)
4966 uint16_t a = OP[0], b = (GPR (OP[1]));
4967 uint16_t tmp1 = a + (PSR_C);
4968 uint16_t tmp = (~tmp1 + 1 + b);
4969 trace_input ("subcw", OP_CONSTANT4, OP_REG, OP_VOID);
4970 /* see ../common/sim-alu.h for a more extensive discussion on how to
4971 compute the carry/overflow bits. */
4972 SET_PSR_C (tmp > 0xffff);
4973 SET_PSR_F (((a & 0x8000) != (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
4974 SET_GPR (OP[1], tmp);
4975 trace_output_16 (sd, tmp);
4980 OP_3EB_C (SIM_DESC sd, SIM_CPU *cpu)
4983 uint16_t b = GPR (OP[1]);
4984 uint16_t tmp1 = a + (PSR_C);
4985 uint16_t tmp = (~tmp1 + 1 + b);
4986 trace_input ("subcw", OP_CONSTANT16, OP_REG, OP_VOID);
4987 /* see ../common/sim-alu.h for a more extensive discussion on how to
4988 compute the carry/overflow bits. */
4989 SET_PSR_C (tmp > 0xffff);
4990 SET_PSR_F (((a & 0x8000) != (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
4991 SET_GPR (OP[1], tmp);
4992 trace_output_16 (sd, tmp);
4997 OP_3F_8 (SIM_DESC sd, SIM_CPU *cpu)
4999 uint16_t a = (GPR (OP[0])), b = (GPR (OP[1]));
5000 uint16_t tmp1 = a + (PSR_C);
5001 uint16_t tmp = (~tmp1 + 1 + b);
5002 trace_input ("subcw", OP_REG, OP_REG, OP_VOID);
5003 /* see ../common/sim-alu.h for a more extensive discussion on how to
5004 compute the carry/overflow bits. */
5005 SET_PSR_C (tmp > 0xffff);
5006 SET_PSR_F (((a & 0x8000) != (b & 0x8000)) && ((b & 0x8000) != (tmp & 0x8000)));
5007 SET_GPR (OP[1], tmp);
5008 trace_output_16 (sd, tmp);
5013 OP_3_C (SIM_DESC sd, SIM_CPU *cpu)
5016 uint32_t b = GPR32 (OP[1]);
5017 uint32_t tmp = (~a + 1 + b);
5018 trace_input ("subd", OP_CONSTANT32, OP_REGP, OP_VOID);
5019 /* see ../common/sim-alu.h for a more extensive discussion on how to
5020 compute the carry/overflow bits. */
5021 SET_PSR_C (tmp > 0xffffffff);
5022 SET_PSR_F (((a & 0x80000000) != (b & 0x80000000)) &&
5023 ((b & 0x80000000) != (tmp & 0x80000000)));
5024 SET_GPR32 (OP[1], tmp);
5025 trace_output_32 (sd, tmp);
5030 OP_14C_14 (SIM_DESC sd, SIM_CPU *cpu)
5032 uint32_t a = GPR32 (OP[0]);
5033 uint32_t b = GPR32 (OP[1]);
5034 uint32_t tmp = (~a + 1 + b);
5035 trace_input ("subd", OP_REGP, OP_REGP, OP_VOID);
5036 /* see ../common/sim-alu.h for a more extensive discussion on how to
5037 compute the carry/overflow bits. */
5038 SET_PSR_C (tmp > 0xffffffff);
5039 SET_PSR_F (((a & 0x80000000) != (b & 0x80000000)) &&
5040 ((b & 0x80000000) != (tmp & 0x80000000)));
5041 SET_GPR32 (OP[1], tmp);
5042 trace_output_32 (sd, tmp);
5047 OP_C_C (SIM_DESC sd, SIM_CPU *cpu)
5049 host_callback *cb = STATE_CALLBACK (sd);
5052 trace_input ("excp", OP_CONSTANT4, OP_VOID, OP_VOID);
5056 #if (DEBUG & DEBUG_TRAP) == 0
5059 uint16_t vec = OP[0] + TRAP_VECTOR_START;
5062 SET_PSR (PSR & PSR_SM_BIT);
5067 #else /* if debugging use trap to print registers */
5070 static int first_time = 1;
5075 sim_io_printf (sd, "Trap # PC ");
5076 for (i = 0; i < 16; i++)
5077 sim_io_printf (sd, " %sr%d", (i > 9) ? "" : " ", i);
5078 sim_io_printf (sd, " a0 a1 f0 f1 c\n");
5081 sim_io_printf (sd, "Trap %2d 0x%.4x:", (int)OP[0], (int)PC);
5083 for (i = 0; i < 16; i++)
5084 sim_io_printf (sd, " %.4x", (int) GPR (i));
5086 for (i = 0; i < 2; i++)
5087 sim_io_printf (sd, " %.2x%.8lx",
5088 ((int)(ACC (i) >> 32) & 0xff),
5089 ((unsigned long) ACC (i)) & 0xffffffff);
5091 sim_io_printf (sd, " %d %d %d\n",
5092 PSR_F != 0, PSR_F != 0, PSR_C != 0);
5093 sim_io_flush_stdout (sd);
5097 case 8: /* new system call trap */
5098 /* Trap 8 is used for simulating low-level I/O */
5100 uint32_t result = 0;
5103 /* Registers passed to trap 0. */
5105 #define FUNC GPR (0) /* function number. */
5106 #define PARM1 GPR (2) /* optional parm 1. */
5107 #define PARM2 GPR (3) /* optional parm 2. */
5108 #define PARM3 GPR (4) /* optional parm 3. */
5109 #define PARM4 GPR (5) /* optional parm 4. */
5111 /* Registers set by trap 0 */
5113 #define RETVAL(X) do { result = (0xffff & (X));SET_GPR (0, result);} while (0)
5114 #define RETVAL32(X) do { result = (X); SET_GPR32 (0, result);} while (0)
5115 #define RETERR(X) SET_GPR (4, (X)) /* return error code. */
5117 /* Turn a pointer in a register into a pointer into real memory. */
5119 #define MEMPTR(x) sim_core_trans_addr (sd, cpu, read_map, x)
5123 #if !defined(__GO32__) && !defined(_WIN32)
5124 case TARGET_NEWLIB_CR16_SYS_fork:
5125 trace_input ("<fork>", OP_VOID, OP_VOID, OP_VOID);
5127 trace_output_16 (sd, result);
5131 case TARGET_NEWLIB_CR16_SYS_getpid:
5132 trace_input ("<getpid>", OP_VOID, OP_VOID, OP_VOID);
5134 trace_output_16 (sd, result);
5137 case TARGET_NEWLIB_CR16_SYS_kill:
5138 trace_input ("<kill>", OP_REG, OP_REG, OP_VOID);
5139 if (PARM1 == getpid ())
5141 trace_output_void (sd);
5150 case 1: os_sig = SIGHUP; break;
5153 case 2: os_sig = SIGINT; break;
5156 case 3: os_sig = SIGQUIT; break;
5159 case 4: os_sig = SIGILL; break;
5162 case 5: os_sig = SIGTRAP; break;
5165 case 6: os_sig = SIGABRT; break;
5166 #elif defined(SIGIOT)
5167 case 6: os_sig = SIGIOT; break;
5170 case 7: os_sig = SIGEMT; break;
5173 case 8: os_sig = SIGFPE; break;
5176 case 9: os_sig = SIGKILL; break;
5179 case 10: os_sig = SIGBUS; break;
5182 case 11: os_sig = SIGSEGV; break;
5185 case 12: os_sig = SIGSYS; break;
5188 case 13: os_sig = SIGPIPE; break;
5191 case 14: os_sig = SIGALRM; break;
5194 case 15: os_sig = SIGTERM; break;
5197 case 16: os_sig = SIGURG; break;
5200 case 17: os_sig = SIGSTOP; break;
5203 case 18: os_sig = SIGTSTP; break;
5206 case 19: os_sig = SIGCONT; break;
5209 case 20: os_sig = SIGCHLD; break;
5210 #elif defined(SIGCLD)
5211 case 20: os_sig = SIGCLD; break;
5214 case 21: os_sig = SIGTTIN; break;
5217 case 22: os_sig = SIGTTOU; break;
5220 case 23: os_sig = SIGIO; break;
5221 #elif defined (SIGPOLL)
5222 case 23: os_sig = SIGPOLL; break;
5225 case 24: os_sig = SIGXCPU; break;
5228 case 25: os_sig = SIGXFSZ; break;
5231 case 26: os_sig = SIGVTALRM; break;
5234 case 27: os_sig = SIGPROF; break;
5237 case 28: os_sig = SIGWINCH; break;
5240 case 29: os_sig = SIGLOST; break;
5243 case 30: os_sig = SIGUSR1; break;
5246 case 31: os_sig = SIGUSR2; break;
5252 trace_output_void (sd);
5253 sim_io_printf (sd, "Unknown signal %d\n", PARM2);
5254 sim_io_flush_stdout (sd);
5255 EXCEPTION (SIM_SIGILL);
5259 RETVAL (kill (PARM1, PARM2));
5260 trace_output_16 (sd, result);
5265 case TARGET_NEWLIB_CR16_SYS_execve:
5266 trace_input ("<execve>", OP_VOID, OP_VOID, OP_VOID);
5267 RETVAL (execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2<<16|PARM3),
5268 (char **)MEMPTR (PARM4)));
5269 trace_output_16 (sd, result);
5272 case TARGET_NEWLIB_CR16_SYS_execv:
5273 trace_input ("<execv>", OP_VOID, OP_VOID, OP_VOID);
5274 RETVAL (execve (MEMPTR (PARM1), (char **) MEMPTR (PARM2), NULL));
5275 trace_output_16 (sd, result);
5278 case TARGET_NEWLIB_CR16_SYS_pipe:
5283 trace_input ("<pipe>", OP_VOID, OP_VOID, OP_VOID);
5285 RETVAL (pipe (host_fd));
5286 SW (buf, host_fd[0]);
5287 buf += sizeof(uint16_t);
5288 SW (buf, host_fd[1]);
5289 trace_output_16 (sd, result);
5293 case TARGET_NEWLIB_CR16_SYS_wait:
5296 trace_input ("<wait>", OP_REG, OP_VOID, OP_VOID);
5297 RETVAL (wait (&status));
5300 trace_output_16 (sd, result);
5304 case TARGET_NEWLIB_CR16_SYS_getpid:
5305 trace_input ("<getpid>", OP_VOID, OP_VOID, OP_VOID);
5307 trace_output_16 (sd, result);
5310 case TARGET_NEWLIB_CR16_SYS_kill:
5311 trace_input ("<kill>", OP_REG, OP_REG, OP_VOID);
5312 trace_output_void (sd);
5317 case TARGET_NEWLIB_CR16_SYS_read:
5318 trace_input ("<read>", OP_REG, OP_MEMREF, OP_REG);
5319 RETVAL (cb->read (cb, PARM1,
5320 MEMPTR (((unsigned long)PARM3 << 16)
5321 | ((unsigned long)PARM2)), PARM4));
5322 trace_output_16 (sd, result);
5325 case TARGET_NEWLIB_CR16_SYS_write:
5326 trace_input ("<write>", OP_REG, OP_MEMREF, OP_REG);
5327 RETVAL ((int)cb->write (cb, PARM1,
5328 MEMPTR (((unsigned long)PARM3 << 16)
5330 trace_output_16 (sd, result);
5333 case TARGET_NEWLIB_CR16_SYS_lseek:
5334 trace_input ("<lseek>", OP_REG, OP_REGP, OP_REG);
5335 RETVAL32 (cb->lseek (cb, PARM1, ((((long) PARM3) << 16) | PARM2),
5337 trace_output_32 (sd, result);
5340 case TARGET_NEWLIB_CR16_SYS_close:
5341 trace_input ("<close>", OP_REG, OP_VOID, OP_VOID);
5342 RETVAL (cb->close (cb, PARM1));
5343 trace_output_16 (sd, result);
5346 case TARGET_NEWLIB_CR16_SYS_open:
5347 trace_input ("<open>", OP_MEMREF, OP_REG, OP_VOID);
5348 RETVAL32 (cb->open (cb, MEMPTR ((((unsigned long)PARM2) << 16)
5350 trace_output_32 (sd, result);
5353 case TARGET_NEWLIB_CR16_SYS_rename:
5354 trace_input ("<rename>", OP_MEMREF, OP_MEMREF, OP_VOID);
5355 RETVAL (cb->rename (cb, MEMPTR ((((unsigned long)PARM2) << 16) | PARM1),
5356 MEMPTR ((((unsigned long)PARM4) << 16) | PARM3)));
5357 trace_output_16 (sd, result);
5360 case 0x408: /* REVISIT: Added a dummy getenv call. */
5361 trace_input ("<getenv>", OP_MEMREF, OP_MEMREF, OP_VOID);
5363 trace_output_32 (sd, result);
5366 case TARGET_NEWLIB_CR16_SYS_exit:
5367 trace_input ("<exit>", OP_VOID, OP_VOID, OP_VOID);
5368 trace_output_void (sd);
5369 sim_engine_halt (sd, cpu, NULL, PC, sim_exited, GPR (2));
5372 case TARGET_NEWLIB_CR16_SYS_unlink:
5373 trace_input ("<unlink>", OP_MEMREF, OP_VOID, OP_VOID);
5374 RETVAL (cb->unlink (cb, MEMPTR (((unsigned long)PARM2 << 16) | PARM1)));
5375 trace_output_16 (sd, result);
5378 case TARGET_NEWLIB_CR16_SYS_stat:
5379 trace_input ("<stat>", OP_VOID, OP_VOID, OP_VOID);
5380 /* stat system call. */
5382 struct stat host_stat;
5385 RETVAL (stat (MEMPTR ((((unsigned long)PARM2) << 16)|PARM1), &host_stat));
5389 /* The hard-coded offsets and sizes were determined by using
5390 * the CR16 compiler on a test program that used struct stat.
5392 SW (buf, host_stat.st_dev);
5393 SW (buf+2, host_stat.st_ino);
5394 SW (buf+4, host_stat.st_mode);
5395 SW (buf+6, host_stat.st_nlink);
5396 SW (buf+8, host_stat.st_uid);
5397 SW (buf+10, host_stat.st_gid);
5398 SW (buf+12, host_stat.st_rdev);
5399 SLW (buf+16, host_stat.st_size);
5400 SLW (buf+20, host_stat.st_atime);
5401 SLW (buf+28, host_stat.st_mtime);
5402 SLW (buf+36, host_stat.st_ctime);
5404 trace_output_16 (sd, result);
5407 case TARGET_NEWLIB_CR16_SYS_chown:
5408 trace_input ("<chown>", OP_VOID, OP_VOID, OP_VOID);
5409 RETVAL (chown (MEMPTR (PARM1), PARM2, PARM3));
5410 trace_output_16 (sd, result);
5413 case TARGET_NEWLIB_CR16_SYS_chmod:
5414 trace_input ("<chmod>", OP_VOID, OP_VOID, OP_VOID);
5415 RETVAL (chmod (MEMPTR (PARM1), PARM2));
5416 trace_output_16 (sd, result);
5419 case TARGET_NEWLIB_CR16_SYS_utime:
5420 trace_input ("<utime>", OP_REG, OP_REG, OP_REG);
5421 /* Cast the second argument to void *, to avoid type mismatch
5422 if a prototype is present. */
5423 RETVAL (utime (MEMPTR (PARM1), (void *) MEMPTR (PARM2)));
5424 trace_output_16 (sd, result);
5427 case TARGET_NEWLIB_CR16_SYS_time:
5428 trace_input ("<time>", OP_VOID, OP_VOID, OP_REG);
5429 RETVAL32 (time (NULL));
5430 trace_output_32 (sd, result);
5437 case TRAP_BREAKPOINT:
5440 trace_output_void (sd);
5441 EXCEPTION (SIM_SIGTRAP);
5443 case SIGTRAP: /* supervisor call ? */
5444 trace_output_void (sd);
5445 sim_engine_halt (sd, cpu, NULL, PC, sim_exited, GPR (2));
5448 cb->error (cb, "Unknown syscall %d", FUNC);
5452 if ((uint16_t) result == (uint16_t) -1)
5453 RETERR (cb->get_errno (cb));
5464 OP_3_9 (SIM_DESC sd, SIM_CPU *cpu)
5466 uint16_t a = OP[0] + 1, b = OP[1], c = OP[2], i = 0;
5467 uint32_t tmp, sp_addr = (GPR32 (15)) - (a * 2) - 4, is_regp = 0;
5468 trace_input ("push", OP_CONSTANT3, OP_REG, OP_REG);
5474 SW (sp_addr, (GPR (b+i)));
5480 tmp = (GPR32 (b+i));
5482 tmp = (GPR32 (b+i-1));
5501 /* Store RA address. */
5505 sp_addr = (GPR32 (15)) - (a * 2) - 4;
5506 SET_GPR32 (15, sp_addr); /* Update SP address. */
5508 trace_output_void (sd);
5513 OP_1_8 (SIM_DESC sd, SIM_CPU *cpu)
5515 uint32_t sp_addr, tmp, is_regp = 0;
5516 uint16_t a = OP[0] + 1, b = OP[1], c = OP[2], i = 0;
5517 trace_input ("push", OP_CONSTANT3, OP_REG, OP_VOID);
5520 sp_addr = (GPR32 (15)) - (a * 2) - 4;
5522 sp_addr = (GPR32 (15)) - (a * 2);
5528 SW (sp_addr, (GPR (b+i)));
5534 tmp = (GPR32 (b+i));
5536 tmp = (GPR32 (b+i-1));
5555 /* Store RA address. */
5558 sp_addr = (GPR32 (15)) - (a * 2) - 4;
5561 sp_addr = (GPR32 (15)) - (a * 2);
5563 SET_GPR32 (15, sp_addr); /* Update SP address. */
5565 trace_output_void (sd);
5571 OP_11E_10 (SIM_DESC sd, SIM_CPU *cpu)
5573 uint32_t sp_addr = (GPR32 (15)), tmp;
5574 trace_input ("push", OP_VOID, OP_VOID, OP_VOID);
5576 SLW(sp_addr-4,tmp); /* Store RA address. */
5577 SET_GPR32 (15, (sp_addr - 4)); /* Update SP address. */
5578 trace_output_void (sd);
5584 OP_5_9 (SIM_DESC sd, SIM_CPU *cpu)
5586 uint16_t a = OP[0] + 1, b = OP[1], c = OP[2], i = 0;
5587 uint32_t tmp, sp_addr = (GPR32 (15)), is_regp = 0;;
5588 trace_input ("pop", OP_CONSTANT3, OP_REG, OP_REG);
5594 SET_GPR ((b+i), RW(sp_addr));
5610 tmp = (tmp << 16) | (GPR32 (b+i));
5612 tmp = (tmp << 16) | (GPR32 (b+i-1));
5616 SET_GPR32 ((b+i), (((tmp & 0xffff) << 16)
5617 | ((tmp >> 16) & 0xffff)));
5619 SET_GPR32 ((b+i-1), (((tmp & 0xffff) << 16)
5620 | ((tmp >> 16) & 0xffff)));
5627 tmp = RLW(sp_addr); /* store RA also. */
5628 SET_GPR32 (14, (((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff)));
5630 SET_GPR32 (15, (sp_addr + 4)); /* Update SP address. */
5632 trace_output_void (sd);
5637 OP_2_8 (SIM_DESC sd, SIM_CPU *cpu)
5639 uint16_t a = OP[0] + 1, b = OP[1], c = OP[2], i = 0;
5640 uint32_t tmp, sp_addr = (GPR32 (15)), is_regp = 0;
5641 trace_input ("pop", OP_CONSTANT3, OP_REG, OP_VOID);
5647 SET_GPR ((b+i), RW(sp_addr));
5663 tmp = ((tmp << 16) & 0xffffffff) | (GPR32 (b+i));
5665 tmp = ((tmp << 16) & 0xffffffff) | (GPR32 (b+i-1));
5669 SET_GPR32 ((b+i), (((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff)));
5671 SET_GPR32 ((b+i-1), (((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff)));
5679 tmp = RLW(sp_addr); /* Store RA Reg. */
5680 SET_GPR32 (14, (((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff)));
5684 SET_GPR32 (15, sp_addr); /* Update SP address. */
5686 trace_output_void (sd);
5691 OP_21E_10 (SIM_DESC sd, SIM_CPU *cpu)
5693 uint32_t sp_addr = GPR32 (15);
5695 trace_input ("pop", OP_VOID, OP_VOID, OP_VOID);
5698 SET_GPR32 (14, (((tmp & 0xffff) << 16)| ((tmp >> 16) & 0xffff)));
5699 SET_GPR32 (15, (sp_addr+4)); /* Update SP address. */
5701 trace_output_void (sd);
5706 OP_7_9 (SIM_DESC sd, SIM_CPU *cpu)
5708 uint16_t a = OP[0], b = OP[1];
5709 trace_input ("popret", OP_CONSTANT3, OP_REG, OP_REG);
5711 JMP(((GPR32(14)) << 1) & 0xffffff);
5713 trace_output_void (sd);
5718 OP_3_8 (SIM_DESC sd, SIM_CPU *cpu)
5720 uint16_t a = OP[0], b = OP[1];
5721 trace_input ("popret", OP_CONSTANT3, OP_REG, OP_VOID);
5723 JMP(((GPR32(14)) << 1) & 0xffffff);
5725 trace_output_void (sd);
5730 OP_31E_10 (SIM_DESC sd, SIM_CPU *cpu)
5733 trace_input ("popret", OP_VOID, OP_VOID, OP_VOID);
5734 OP_21E_10 (sd, cpu);
5735 tmp = (((GPR32(14)) << 1) & 0xffffff);
5736 /* If the resulting PC value is less than 0x00_0000 or greater
5737 than 0xFF_FFFF, this instruction causes an IAD trap.*/
5739 if ((tmp < 0x0) || (tmp > 0xFFFFFF))
5741 trace_output_void (sd);
5742 EXCEPTION (SIM_SIGBUS);
5747 trace_output_32 (sd, tmp);
5753 OP_A_10 (SIM_DESC sd, SIM_CPU *cpu)
5755 trace_input ("cinv[i]", OP_VOID, OP_VOID, OP_VOID);
5757 trace_output_void (sd);
5762 OP_B_10 (SIM_DESC sd, SIM_CPU *cpu)
5764 trace_input ("cinv[i,u]", OP_VOID, OP_VOID, OP_VOID);
5766 trace_output_void (sd);
5771 OP_C_10 (SIM_DESC sd, SIM_CPU *cpu)
5773 trace_input ("cinv[d]", OP_VOID, OP_VOID, OP_VOID);
5775 trace_output_void (sd);
5780 OP_D_10 (SIM_DESC sd, SIM_CPU *cpu)
5782 trace_input ("cinv[i,u]", OP_VOID, OP_VOID, OP_VOID);
5784 trace_output_void (sd);
5789 OP_E_10 (SIM_DESC sd, SIM_CPU *cpu)
5791 trace_input ("cinv[d,i]", OP_VOID, OP_VOID, OP_VOID);
5793 trace_output_void (sd);
5798 OP_F_10 (SIM_DESC sd, SIM_CPU *cpu)
5800 trace_input ("cinv[d,i,u]", OP_VOID, OP_VOID, OP_VOID);
5802 trace_output_void (sd);
5807 OP_3_10 (SIM_DESC sd, SIM_CPU *cpu)
5809 trace_input ("retx", OP_VOID, OP_VOID, OP_VOID);
5811 trace_output_void (sd);
5816 OP_4_10 (SIM_DESC sd, SIM_CPU *cpu)
5818 trace_input ("di", OP_VOID, OP_VOID, OP_VOID);
5820 trace_output_void (sd);
5825 OP_5_10 (SIM_DESC sd, SIM_CPU *cpu)
5827 trace_input ("ei", OP_VOID, OP_VOID, OP_VOID);
5829 trace_output_void (sd);
5834 OP_6_10 (SIM_DESC sd, SIM_CPU *cpu)
5836 trace_input ("wait", OP_VOID, OP_VOID, OP_VOID);
5837 trace_output_void (sd);
5838 EXCEPTION (SIM_SIGTRAP);
5843 OP_7_10 (SIM_DESC sd, SIM_CPU *cpu)
5845 trace_input ("ewait", OP_VOID, OP_VOID, OP_VOID);
5847 trace_output_void (sd);
5852 OP_28_8 (SIM_DESC sd, SIM_CPU *cpu)
5854 uint8_t tmp, a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
5855 trace_input ("xorb", OP_CONSTANT4, OP_REG, OP_VOID);
5857 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
5858 trace_output_16 (sd, tmp);
5863 OP_28B_C (SIM_DESC sd, SIM_CPU *cpu)
5865 uint8_t tmp, a = (OP[0]) & 0xff, b = (GPR (OP[1])) & 0xff;
5866 trace_input ("xorb", OP_CONSTANT16, OP_REG, OP_VOID);
5868 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
5869 trace_output_16 (sd, tmp);
5874 OP_29_8 (SIM_DESC sd, SIM_CPU *cpu)
5876 uint8_t tmp, a = (GPR (OP[0])) & 0xff, b = (GPR (OP[1])) & 0xff;
5877 trace_input ("xorb", OP_REG, OP_REG, OP_VOID);
5879 SET_GPR (OP[1], (tmp | ((GPR (OP[1])) & 0xff00)));
5880 trace_output_16 (sd, tmp);
5885 OP_2A_8 (SIM_DESC sd, SIM_CPU *cpu)
5887 uint16_t tmp, a = (OP[0]), b = (GPR (OP[1]));
5888 trace_input ("xorw", OP_CONSTANT4, OP_REG, OP_VOID);
5890 SET_GPR (OP[1], tmp);
5891 trace_output_16 (sd, tmp);
5896 OP_2AB_C (SIM_DESC sd, SIM_CPU *cpu)
5898 uint16_t tmp, a = (OP[0]), b = (GPR (OP[1]));
5899 trace_input ("xorw", OP_CONSTANT16, OP_REG, OP_VOID);
5901 SET_GPR (OP[1], tmp);
5902 trace_output_16 (sd, tmp);
5907 OP_2B_8 (SIM_DESC sd, SIM_CPU *cpu)
5909 uint16_t tmp, a = (GPR (OP[0])), b = (GPR (OP[1]));
5910 trace_input ("xorw", OP_REG, OP_REG, OP_VOID);
5912 SET_GPR (OP[1], tmp);
5913 trace_output_16 (sd, tmp);
5916 /*REVISIT FOR LPR/SPR . */
5920 OP_140_14 (SIM_DESC sd, SIM_CPU *cpu)
5922 uint16_t a = GPR (OP[0]);
5923 trace_input ("lpr", OP_REG, OP_REG, OP_VOID);
5924 SET_CREG (OP[1], a);
5925 trace_output_16 (sd, a);
5930 OP_141_14 (SIM_DESC sd, SIM_CPU *cpu)
5932 uint32_t a = GPR32 (OP[0]);
5933 trace_input ("lprd", OP_REGP, OP_REG, OP_VOID);
5934 SET_CREG (OP[1], a);
5935 trace_output_flag (sd);
5940 OP_142_14 (SIM_DESC sd, SIM_CPU *cpu)
5942 uint16_t a = CREG (OP[0]);
5943 trace_input ("spr", OP_REG, OP_REG, OP_VOID);
5945 trace_output_16 (sd, a);
5950 OP_143_14 (SIM_DESC sd, SIM_CPU *cpu)
5952 uint32_t a = CREG (OP[0]);
5953 trace_input ("sprd", OP_REGP, OP_REGP, OP_VOID);
5954 SET_GPR32 (OP[1], a);
5955 trace_output_32 (sd, a);
5960 OP_0_20 (SIM_DESC sd, SIM_CPU *cpu)
5962 trace_input ("null", OP_VOID, OP_VOID, OP_VOID);
5963 sim_engine_halt (sd, cpu, NULL, PC, sim_exited, 0);