1 /* Simulation code for the CR16 processor.
2 Copyright (C) 2008-2024 Free Software Foundation, Inc.
3 Contributed by M Ranga Swami Reddy <MR.Swami.Reddy@nsc.com>
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"
46 #define EXCEPTION(sig) sim_engine_halt (sd, cpu, NULL, PC, sim_stopped, sig)
107 PSR_MASK
= (PSR_I_BIT
117 /* The following bits in the PSR _can't_ be set by instructions such
119 PSR_HW_MASK
= (PSR_MASK
)
122 /* cond Code Condition True State
123 * EQ Equal Z flag is 1
124 * NE Not Equal Z flag is 0
125 * CS Carry Set C flag is 1
126 * CC Carry Clear C flag is 0
127 * HI Higher L flag is 1
128 * LS Lower or Same L flag is 0
129 * GT Greater Than N flag is 1
130 * LE Less Than or Equal To N flag is 0
131 * FS Flag Set F flag is 1
132 * FC Flag Clear F flag is 0
133 * LO Lower Z and L flags are 0
134 * HS Higher or Same Z or L flag is 1
135 * LT Less Than Z and N flags are 0
136 * GE Greater Than or Equal To Z or N flag is 1. */
138 static int cond_stat(int cond
)
142 case 0: return PSR_Z
; break;
143 case 1: return !PSR_Z
; break;
144 case 2: return PSR_C
; break;
145 case 3: return !PSR_C
; break;
146 case 4: return PSR_L
; break;
147 case 5: return !PSR_L
; break;
148 case 6: return PSR_N
; break;
149 case 7: return !PSR_N
; break;
150 case 8: return PSR_F
; break;
151 case 9: return !PSR_F
; break;
152 case 10: return !PSR_Z
&& !PSR_L
; break;
153 case 11: return PSR_Z
|| PSR_L
; break;
154 case 12: return !PSR_Z
&& !PSR_N
; break;
155 case 13: return PSR_Z
|| PSR_N
; break;
156 case 14: return 1; break; /*ALWAYS. */
158 // case NEVER: return false; break;
160 //panic("Shouldn't have NO_COND_CODE in an actual instruction!");
168 move_to_cr (SIM_DESC sd
, SIM_CPU
*cpu
, int cr
, creg_t mask
, creg_t val
, int psw_hw_p
)
170 /* A MASK bit is set when the corresponding bit in the CR should
172 /* This assumes that (VAL & MASK) == 0. */
183 "ERROR at PC 0x%x: ST can only be set when FX is set.\n", PC
);
184 EXCEPTION (SIM_SIGILL
);
186 /* keep an up-to-date psw around for tracing. */
187 State
.trace
.psw
= (State
.trace
.psw
& mask
) | val
;
192 /* only issue an update if the register is being changed. */
193 if ((State
.cregs
[cr
] & ~mask
) != val
)
194 SLOT_PEND_MASK (State
.cregs
[cr
], mask
, val
);
200 static void trace_input_func (SIM_DESC sd
,
206 #define trace_input(name, in1, in2, in3) do { if (cr16_debug) trace_input_func (sd, name, in1, in2, in3); } while (0)
208 #ifndef SIZE_INSTRUCTION
209 #define SIZE_INSTRUCTION 8
212 #ifndef SIZE_OPERANDS
213 #define SIZE_OPERANDS 18
217 #define SIZE_VALUES 13
220 #ifndef SIZE_LOCATION
221 #define SIZE_LOCATION 20
228 #ifndef SIZE_LINE_NUMBER
229 #define SIZE_LINE_NUMBER 2
233 trace_input_func (SIM_DESC sd
, const char *name
, enum op_types in1
, enum op_types in2
, enum op_types in3
)
242 const char *filename
;
243 const char *functionname
;
244 unsigned int linenumber
;
247 if ((cr16_debug
& DEBUG_TRACE
) == 0)
250 switch (State
.ins_type
)
253 case INS_UNKNOWN
: type
= " ?"; break;
256 if ((cr16_debug
& DEBUG_LINE_NUMBER
) == 0)
259 SIZE_PC
, (unsigned)PC
,
261 SIZE_INSTRUCTION
, name
);
267 if (STATE_TEXT_SECTION (sd
)
268 && byte_pc
>= STATE_TEXT_START (sd
)
269 && byte_pc
< STATE_TEXT_END (sd
))
271 filename
= (const char *)0;
272 functionname
= (const char *)0;
274 if (bfd_find_nearest_line (STATE_PROG_BFD (sd
),
275 STATE_TEXT_SECTION (sd
),
276 (struct bfd_symbol
**)0,
277 byte_pc
- STATE_TEXT_START (sd
),
278 &filename
, &functionname
, &linenumber
))
283 sprintf (p
, "#%-*d ", SIZE_LINE_NUMBER
, linenumber
);
288 sprintf (p
, "%-*s ", SIZE_LINE_NUMBER
+1, "---");
289 p
+= SIZE_LINE_NUMBER
+2;
294 sprintf (p
, "%s ", functionname
);
299 char *q
= strrchr (filename
, '/');
300 sprintf (p
, "%s ", (q
) ? q
+1 : filename
);
310 "0x%.*x %s: %-*.*s %-*s ",
311 SIZE_PC
, (unsigned)PC
,
313 SIZE_LOCATION
, SIZE_LOCATION
, buf
,
314 SIZE_INSTRUCTION
, name
);
322 for (i
= 0; i
< 3; i
++)
331 sprintf (p
, "%sr%d", comma
, OP
[i
]);
337 sprintf (p
, "%scr%d", comma
, OP
[i
]);
343 sprintf (p
, "%s%d", comma
, OP
[i
]);
349 sprintf (p
, "%s%d", comma
, SEXT4(OP
[i
]));
355 sprintf (p
, "%s%d", comma
, SEXT3(OP
[i
]));
361 sprintf (p
, "%s@r%d", comma
, OP
[i
]);
367 sprintf (p
, "%s@(%d,r%d)", comma
, (int16_t)OP
[i
], OP
[i
+1]);
373 sprintf (p
, "%s@%d", comma
, OP
[i
]);
380 if ((cr16_debug
& DEBUG_VALUES
) == 0)
384 sim_io_printf (sd
, "%s", buf
);
389 sim_io_printf (sd
, "%-*s", SIZE_OPERANDS
, buf
);
392 for (i
= 0; i
< 3; i
++)
398 sim_io_printf (sd
, "%*s", SIZE_VALUES
, "");
402 sim_io_printf (sd
, "%*s0x%.4x", SIZE_VALUES
-6, "",
403 (uint16_t) GPR (OP
[i
]));
407 tmp
= (long)((((uint32_t) GPR (OP
[i
])) << 16) | ((uint32_t) GPR (OP
[i
] + 1)));
408 sim_io_printf (sd
, "%*s0x%.8lx", SIZE_VALUES
-10, "", tmp
);
412 sim_io_printf (sd
, "%*s0x%.4x", SIZE_VALUES
-6, "",
413 (uint16_t) CREG (OP
[i
]));
417 sim_io_printf (sd
, "%*s0x%.4x", SIZE_VALUES
-6, "",
422 sim_io_printf (sd
, "%*s0x%.4x", SIZE_VALUES
-6, "",
423 (uint16_t)SEXT4(OP
[i
]));
427 sim_io_printf (sd
, "%*s0x%.4x", SIZE_VALUES
-6, "",
428 (uint16_t)SEXT3(OP
[i
]));
432 sim_io_printf (sd
, "%*s0x%.4x", SIZE_VALUES
-6, "",
434 sim_io_printf (sd
, "%*s0x%.4x", SIZE_VALUES
-6, "",
435 (uint16_t)GPR (OP
[i
+ 1]));
442 sim_io_flush_stdout (sd
);
446 do_trace_output_flush (SIM_DESC sd
)
448 sim_io_flush_stdout (sd
);
452 do_trace_output_finish (SIM_DESC sd
)
455 " F0=%d F1=%d C=%d\n",
456 (State
.trace
.psw
& PSR_F_BIT
) != 0,
457 (State
.trace
.psw
& PSR_F_BIT
) != 0,
458 (State
.trace
.psw
& PSR_C_BIT
) != 0);
459 sim_io_flush_stdout (sd
);
464 trace_output_40 (SIM_DESC sd
, uint64_t val
)
466 if ((cr16_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
469 " :: %*s0x%.2x%.8lx",
472 ((int)(val
>> 32) & 0xff),
473 ((unsigned long) val
) & 0xffffffff);
474 do_trace_output_finish ();
480 trace_output_32 (SIM_DESC sd
, uint32_t val
)
482 if ((cr16_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
489 do_trace_output_finish (sd
);
494 trace_output_16 (SIM_DESC sd
, uint16_t val
)
496 if ((cr16_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
503 do_trace_output_finish (sd
);
508 trace_output_void (SIM_DESC sd
)
510 if ((cr16_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
512 sim_io_printf (sd
, "\n");
513 do_trace_output_flush (sd
);
518 trace_output_flag (SIM_DESC sd
)
520 if ((cr16_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
526 do_trace_output_finish (sd
);
534 #define trace_input(NAME, IN1, IN2, IN3)
535 #define trace_output(RESULT)
540 OP_2C_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
543 uint8_t a
= OP
[0] & 0xff;
544 uint16_t b
= (GPR (OP
[1])) & 0xff;
545 trace_input ("addub", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
546 tmp
= (a
+ b
) & 0xff;
547 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
548 trace_output_16 (sd
, tmp
);
553 OP_2CB_C (SIM_DESC sd
, SIM_CPU
*cpu
)
556 uint8_t a
= ((OP
[0]) & 0xff), b
= (GPR (OP
[1])) & 0xff;
557 trace_input ("addub", OP_CONSTANT16
, OP_REG
, OP_VOID
);
558 tmp
= (a
+ b
) & 0xff;
559 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
560 trace_output_16 (sd
, tmp
);
565 OP_2D_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
567 uint8_t a
= (GPR (OP
[0])) & 0xff;
568 uint8_t b
= (GPR (OP
[1])) & 0xff;
569 uint16_t tmp
= (a
+ b
) & 0xff;
570 trace_input ("addub", OP_REG
, OP_REG
, OP_VOID
);
571 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
572 trace_output_16 (sd
, tmp
);
577 OP_2E_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
580 uint16_t b
= GPR (OP
[1]);
581 uint16_t tmp
= (a
+ b
);
582 trace_input ("adduw", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
583 SET_GPR (OP
[1], tmp
);
584 trace_output_16 (sd
, tmp
);
589 OP_2EB_C (SIM_DESC sd
, SIM_CPU
*cpu
)
592 uint16_t b
= GPR (OP
[1]);
593 uint16_t tmp
= (a
+ b
);
594 trace_input ("adduw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
595 SET_GPR (OP
[1], tmp
);
596 trace_output_16 (sd
, tmp
);
601 OP_2F_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
603 uint16_t a
= GPR (OP
[0]);
604 uint16_t b
= GPR (OP
[1]);
605 uint16_t tmp
= (a
+ b
);
606 trace_input ("adduw", OP_REG
, OP_REG
, OP_VOID
);
607 SET_GPR (OP
[1], tmp
);
608 trace_output_16 (sd
, tmp
);
613 OP_30_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
616 uint8_t b
= (GPR (OP
[1]) & 0xff);
617 uint16_t tmp
= (a
+ b
) & 0xff;
618 trace_input ("addb", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
619 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
620 SET_PSR_C (tmp
> 0xFF);
621 SET_PSR_F (((a
& 0x80) == (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
622 trace_output_16 (sd
, tmp
);
627 OP_30B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
629 uint8_t a
= (OP
[0]) & 0xff;
630 uint8_t b
= (GPR (OP
[1]) & 0xff);
631 uint16_t tmp
= (a
+ b
) & 0xff;
632 trace_input ("addb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
633 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
634 SET_PSR_C (tmp
> 0xFF);
635 SET_PSR_F (((a
& 0x80) == (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
636 trace_output_16 (sd
, tmp
);
641 OP_31_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
643 uint8_t a
= (GPR (OP
[0]) & 0xff);
644 uint8_t b
= (GPR (OP
[1]) & 0xff);
645 uint16_t tmp
= (a
+ b
) & 0xff;
646 trace_input ("addb", OP_REG
, OP_REG
, OP_VOID
);
647 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
648 SET_PSR_C (tmp
> 0xFF);
649 SET_PSR_F (((a
& 0x80) == (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
650 trace_output_16 (sd
, tmp
);
655 OP_32_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
658 uint16_t tmp
, b
= GPR (OP
[1]);
660 trace_input ("addw", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
661 SET_GPR (OP
[1], tmp
);
662 SET_PSR_C (tmp
> 0xFFFF);
663 SET_PSR_F (((a
& 0x8000) == (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
664 trace_output_16 (sd
, tmp
);
669 OP_32B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
672 uint16_t tmp
, b
= GPR (OP
[1]);
674 trace_input ("addw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
675 SET_GPR (OP
[1], tmp
);
676 SET_PSR_C (tmp
> 0xFFFF);
677 SET_PSR_F (((a
& 0x8000) == (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
678 trace_output_16 (sd
, tmp
);
683 OP_33_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
685 uint16_t tmp
, a
= (GPR (OP
[0])), b
= (GPR (OP
[1]));
686 trace_input ("addw", OP_REG
, OP_REG
, OP_VOID
);
688 SET_GPR (OP
[1], tmp
);
689 SET_PSR_C (tmp
> 0xFFFF);
690 SET_PSR_F (((a
& 0x8000) == (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
691 trace_output_16 (sd
, tmp
);
696 OP_34_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
698 uint8_t tmp
, a
= OP
[0] & 0xff, b
= (GPR (OP
[1])) & 0xff;
699 trace_input ("addcb", OP_CONSTANT4_1
, OP_REG
, OP_REG
);
700 tmp
= (a
+ b
+ PSR_C
) & 0xff;
701 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
702 SET_PSR_C (tmp
> 0xFF);
703 SET_PSR_F (((a
& 0x80) == (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
704 trace_output_16 (sd
, tmp
);
709 OP_34B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
711 int8_t a
= OP
[0] & 0xff;
712 uint8_t b
= (GPR (OP
[1])) & 0xff;
713 uint8_t tmp
= (a
+ b
+ PSR_C
) & 0xff;
714 trace_input ("addcb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
715 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
716 SET_PSR_C (tmp
> 0xFF);
717 SET_PSR_F (((a
& 0x80) == (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
718 trace_output_16 (sd
, tmp
);
723 OP_35_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
725 uint8_t a
= (GPR (OP
[0])) & 0xff;
726 uint8_t b
= (GPR (OP
[1])) & 0xff;
727 uint8_t tmp
= (a
+ b
+ PSR_C
) & 0xff;
728 trace_input ("addcb", OP_REG
, OP_REG
, OP_VOID
);
729 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
730 SET_PSR_C (tmp
> 0xFF);
731 SET_PSR_F (((a
& 0x80) == (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
732 trace_output_16 (sd
, tmp
);
737 OP_36_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
740 uint16_t b
= GPR (OP
[1]);
741 uint16_t tmp
= (a
+ b
+ PSR_C
);
742 trace_input ("addcw", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
743 SET_GPR (OP
[1], tmp
);
744 SET_PSR_C (tmp
> 0xFFFF);
745 SET_PSR_F (((a
& 0x8000) == (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
746 trace_output_16 (sd
, tmp
);
751 OP_36B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
754 uint16_t b
= GPR (OP
[1]);
755 uint16_t tmp
= (a
+ b
+ PSR_C
);
756 trace_input ("addcw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
757 SET_GPR (OP
[1], tmp
);
758 SET_PSR_C (tmp
> 0xFFFF);
759 SET_PSR_F (((a
& 0x8000) == (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
760 trace_output_16 (sd
, tmp
);
765 OP_37_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
767 uint16_t a
= GPR (OP
[1]);
768 uint16_t b
= GPR (OP
[1]);
769 uint16_t tmp
= (a
+ b
+ PSR_C
);
770 trace_input ("addcw", OP_REG
, OP_REG
, OP_VOID
);
771 SET_GPR (OP
[1], tmp
);
772 SET_PSR_C (tmp
> 0xFFFF);
773 SET_PSR_F (((a
& 0x8000) == (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
774 trace_output_16 (sd
, tmp
);
779 OP_60_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
782 uint32_t b
= GPR32 (OP
[1]);
783 uint32_t tmp
= (a
+ b
);
784 trace_input ("addd", OP_CONSTANT4_1
, OP_REGP
, OP_VOID
);
785 SET_GPR32 (OP
[1], tmp
);
786 SET_PSR_C (tmp
> 0xFFFFFFFF);
787 SET_PSR_F (((a
& 0x80000000) == (b
& 0x80000000)) && ((b
& 0x80000000) != (tmp
& 0x80000000)));
788 trace_output_32 (sd
, tmp
);
793 OP_60B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
795 int32_t a
= (SEXT16(OP
[0]));
796 uint32_t b
= GPR32 (OP
[1]);
797 uint32_t tmp
= (a
+ b
);
798 trace_input ("addd", OP_CONSTANT16
, OP_REGP
, OP_VOID
);
799 SET_GPR32 (OP
[1], tmp
);
800 SET_PSR_C (tmp
> 0xFFFFFFFF);
801 SET_PSR_F (((a
& 0x80000000) == (b
& 0x80000000)) && ((b
& 0x80000000) != (tmp
& 0x80000000)));
802 trace_output_32 (sd
, tmp
);
807 OP_61_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
809 uint32_t a
= GPR32 (OP
[0]);
810 uint32_t b
= GPR32 (OP
[1]);
811 uint32_t tmp
= (a
+ b
);
812 trace_input ("addd", OP_REGP
, OP_REGP
, OP_VOID
);
813 SET_GPR32 (OP
[1], tmp
);
814 trace_output_32 (sd
, tmp
);
815 SET_PSR_C (tmp
> 0xFFFFFFFF);
816 SET_PSR_F (((a
& 0x80000000) == (b
& 0x80000000)) && ((b
& 0x80000000) != (tmp
& 0x80000000)));
821 OP_4_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
824 uint32_t b
= GPR32 (OP
[1]);
826 trace_input ("addd", OP_CONSTANT20
, OP_REGP
, OP_VOID
);
828 SET_GPR32 (OP
[1], tmp
);
829 SET_PSR_C (tmp
> 0xFFFFFFFF);
830 SET_PSR_F (((a
& 0x80000000) == (b
& 0x80000000)) && ((b
& 0x80000000) != (tmp
& 0x80000000)));
831 trace_output_32 (sd
, tmp
);
836 OP_2_C (SIM_DESC sd
, SIM_CPU
*cpu
)
839 uint32_t b
= GPR32 (OP
[1]);
841 trace_input ("addd", OP_CONSTANT32
, OP_REGP
, OP_VOID
);
843 SET_GPR32 (OP
[1], tmp
);
844 SET_PSR_C (tmp
> 0xFFFFFFFF);
845 SET_PSR_F (((a
& 0x80000000) == (b
& 0x80000000)) && ((b
& 0x80000000) != (tmp
& 0x80000000)));
846 trace_output_32 (sd
, tmp
);
851 OP_20_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
853 uint8_t tmp
, a
= (OP
[0]) & 0xff, b
= (GPR (OP
[1])) & 0xff;
854 trace_input ("andb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
856 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
857 trace_output_16 (sd
, tmp
);
862 OP_20B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
864 uint8_t tmp
, a
= (OP
[0]) & 0xff, b
= (GPR (OP
[1])) & 0xff;
865 trace_input ("andb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
867 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
868 trace_output_16 (sd
, tmp
);
873 OP_21_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
875 uint8_t tmp
, a
= (GPR (OP
[0])) & 0xff, b
= (GPR (OP
[1])) & 0xff;
876 trace_input ("andb", OP_REG
, OP_REG
, OP_VOID
);
878 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
879 trace_output_16 (sd
, tmp
);
884 OP_22_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
886 uint16_t tmp
, a
= OP
[0], b
= GPR (OP
[1]);
887 trace_input ("andw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
889 SET_GPR (OP
[1], tmp
);
890 trace_output_16 (sd
, tmp
);
895 OP_22B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
897 uint16_t tmp
, a
= OP
[0], b
= GPR (OP
[1]);
898 trace_input ("andw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
900 SET_GPR (OP
[1], tmp
);
901 trace_output_16 (sd
, tmp
);
906 OP_23_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
908 uint16_t tmp
, a
= GPR (OP
[0]), b
= GPR (OP
[1]);
909 trace_input ("andw", OP_REG
, OP_REG
, OP_VOID
);
911 SET_GPR (OP
[1], tmp
);
912 trace_output_16 (sd
, tmp
);
917 OP_4_C (SIM_DESC sd
, SIM_CPU
*cpu
)
919 uint32_t tmp
, a
= OP
[0], b
= GPR32 (OP
[1]);
920 trace_input ("andd", OP_CONSTANT32
, OP_REGP
, OP_VOID
);
922 SET_GPR32 (OP
[1], tmp
);
923 trace_output_32 (sd
, tmp
);
928 OP_14B_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
930 uint32_t tmp
, a
= (GPR32 (OP
[0])), b
= (GPR32 (OP
[1]));
931 trace_input ("andd", OP_REGP
, OP_REGP
, OP_VOID
);
933 SET_GPR32 (OP
[1], tmp
);
934 trace_output_32 (sd
, tmp
);
939 OP_5_C (SIM_DESC sd
, SIM_CPU
*cpu
)
941 uint32_t tmp
, a
= (OP
[0]), b
= GPR32 (OP
[1]);
942 trace_input ("ord", OP_CONSTANT32
, OP_REG
, OP_VOID
);
944 SET_GPR32 (OP
[1], tmp
);
945 trace_output_32 (sd
, tmp
);
950 OP_149_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
952 uint32_t tmp
, a
= GPR32 (OP
[0]), b
= GPR32 (OP
[1]);
953 trace_input ("ord", OP_REGP
, OP_REGP
, OP_VOID
);
955 SET_GPR32 (OP
[1], tmp
);
956 trace_output_32 (sd
, tmp
);
961 OP_6_C (SIM_DESC sd
, SIM_CPU
*cpu
)
963 uint32_t tmp
, a
= (OP
[0]), b
= GPR32 (OP
[1]);
964 trace_input ("xord", OP_CONSTANT32
, OP_REG
, OP_VOID
);
966 SET_GPR32 (OP
[1], tmp
);
967 trace_output_32 (sd
, tmp
);
972 OP_14A_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
974 uint32_t tmp
, a
= GPR32 (OP
[0]), b
= GPR32 (OP
[1]);
975 trace_input ("xord", OP_REGP
, OP_REGP
, OP_VOID
);
977 SET_GPR32 (OP
[1], tmp
);
978 trace_output_32 (sd
, tmp
);
984 OP_1_4 (SIM_DESC sd
, SIM_CPU
*cpu
)
986 uint32_t tmp
= 0, cond
= cond_stat (OP
[0]);
987 trace_input ("b", OP_CONSTANT4
, OP_DISPE9
, OP_VOID
);
991 tmp
= (PC
- (OP
[1]));
993 tmp
= (PC
+ (OP
[1]));
994 /* If the resulting PC value is less than 0x00_0000 or greater
995 than 0xFF_FFFF, this instruction causes an IAD trap.*/
997 if ((tmp
< 0x000000) || (tmp
> 0xFFFFFF))
999 trace_output_void (sd
);
1000 EXCEPTION (SIM_SIGBUS
);
1005 sign_flag
= 0; /* Reset sign_flag. */
1006 trace_output_32 (sd
, tmp
);
1011 OP_18_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
1013 uint32_t tmp
= 0, cond
= cond_stat (OP
[0]);
1014 trace_input ("b", OP_CONSTANT4
, OP_DISP17
, OP_VOID
);
1021 /* If the resulting PC value is less than 0x00_0000 or greater
1022 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1024 if ((tmp
< 0x000000) || (tmp
> 0xFFFFFF))
1026 trace_output_void (sd
);
1027 EXCEPTION (SIM_SIGBUS
);
1032 sign_flag
= 0; /* Reset sign_flag. */
1033 trace_output_32 (sd
, tmp
);
1038 OP_10_10 (SIM_DESC sd
, SIM_CPU
*cpu
)
1040 uint32_t tmp
= 0, cond
= cond_stat (OP
[0]);
1041 trace_input ("b", OP_CONSTANT4
, OP_DISP25
, OP_VOID
);
1045 tmp
= (PC
- (OP
[1]));
1047 tmp
= (PC
+ (OP
[1]));
1048 /* If the resulting PC value is less than 0x00_0000 or greater
1049 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1051 if ((tmp
< 0x000000) || (tmp
> 0xFFFFFF))
1053 trace_output_void (sd
);
1054 EXCEPTION (SIM_SIGBUS
);
1059 sign_flag
= 0; /* Reset sign_flag. */
1060 trace_output_32 (sd
, tmp
);
1065 OP_C0_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
1068 trace_input ("bal", OP_REG
, OP_DISP17
, OP_VOID
);
1069 tmp
= ((PC
+ 4) >> 1); /* Store PC in RA register. */
1070 SET_GPR32 (14, tmp
);
1072 tmp
= (PC
- (OP
[1]));
1074 tmp
= (PC
+ (OP
[1]));
1076 /* If the resulting PC value is less than 0x00_0000 or greater
1077 than 0xFF_FFFF, this instruction causes an IAD trap. */
1079 if ((tmp
< 0x000000) || (tmp
> 0xFFFFFF))
1081 trace_output_void (sd
);
1082 EXCEPTION (SIM_SIGBUS
);
1086 sign_flag
= 0; /* Reset sign_flag. */
1087 trace_output_32 (sd
, tmp
);
1093 OP_102_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
1096 trace_input ("bal", OP_REGP
, OP_DISP25
, OP_VOID
);
1097 tmp
= (((PC
) + 4) >> 1); /* Store PC in reg pair. */
1098 SET_GPR32 (OP
[0], tmp
);
1100 tmp
= ((PC
) - (OP
[1]));
1102 tmp
= ((PC
) + (OP
[1]));
1103 /* If the resulting PC value is less than 0x00_0000 or greater
1104 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1106 if ((tmp
< 0x000000) || (tmp
> 0xFFFFFF))
1108 trace_output_void (sd
);
1109 EXCEPTION (SIM_SIGBUS
);
1113 sign_flag
= 0; /* Reset sign_flag. */
1114 trace_output_32 (sd
, tmp
);
1119 OP_148_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
1122 trace_input ("jal", OP_REGP
, OP_REGP
, OP_VOID
);
1123 SET_GPR32 (OP
[0], (((PC
) + 4) >> 1)); /* Store next PC in RA */
1124 tmp
= GPR32 (OP
[1]);
1125 tmp
= SEXT24(tmp
<< 1);
1126 /* If the resulting PC value is less than 0x00_0000 or greater
1127 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1129 if ((tmp
< 0x0) || (tmp
> 0xFFFFFF))
1131 trace_output_void (sd
);
1132 EXCEPTION (SIM_SIGBUS
);
1137 trace_output_32 (sd
, tmp
);
1143 OP_D_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1146 trace_input ("jal", OP_REGP
, OP_VOID
, OP_VOID
);
1147 SET_GPR32 (14, (((PC
) + 2) >> 1)); /* Store next PC in RA */
1148 tmp
= GPR32 (OP
[0]);
1149 tmp
= SEXT24(tmp
<< 1);
1150 /* If the resulting PC value is less than 0x00_0000 or greater
1151 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1153 if ((tmp
< 0x0) || (tmp
> 0xFFFFFF))
1155 trace_output_void (sd
);
1156 EXCEPTION (SIM_SIGBUS
);
1161 trace_output_32 (sd
, tmp
);
1167 OP_C_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
1170 uint8_t a
= (GPR (OP
[0]) & 0xFF);
1171 trace_input ("beq0b", OP_REG
, OP_DISP5
, OP_VOID
);
1176 addr
= (PC
- OP
[1]);
1178 addr
= (PC
+ OP
[1]);
1182 sign_flag
= 0; /* Reset sign_flag. */
1183 trace_output_void (sd
);
1188 OP_D_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
1191 uint8_t a
= (GPR (OP
[0]) & 0xFF);
1192 trace_input ("bne0b", OP_REG
, OP_DISP5
, OP_VOID
);
1197 addr
= (PC
- OP
[1]);
1199 addr
= (PC
+ OP
[1]);
1203 sign_flag
= 0; /* Reset sign_flag. */
1204 trace_output_void (sd
);
1209 OP_E_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
1212 uint16_t a
= GPR (OP
[0]);
1213 trace_input ("beq0w", OP_REG
, OP_DISP5
, OP_VOID
);
1218 addr
= (PC
- OP
[1]);
1220 addr
= (PC
+ OP
[1]);
1224 sign_flag
= 0; /* Reset sign_flag. */
1225 trace_output_void (sd
);
1230 OP_F_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
1233 uint16_t a
= GPR (OP
[0]);
1234 trace_input ("bne0w", OP_REG
, OP_DISP5
, OP_VOID
);
1239 addr
= (PC
- OP
[1]);
1241 addr
= (PC
+ OP
[1]);
1245 sign_flag
= 0; /* Reset sign_flag. */
1246 trace_output_void (sd
);
1252 OP_A0_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1255 trace_input ("jeq", OP_REGP
, OP_VOID
, OP_VOID
);
1258 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits. */
1259 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit. */
1261 trace_output_32 (sd
, tmp
);
1266 OP_A1_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1269 trace_input ("jne", OP_REGP
, OP_VOID
, OP_VOID
);
1272 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits. */
1273 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit. */
1275 trace_output_32 (sd
, tmp
);
1280 OP_A2_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1283 trace_input ("jcs", OP_REGP
, OP_VOID
, OP_VOID
);
1286 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1287 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1289 trace_output_32 (sd
, tmp
);
1294 OP_A3_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1297 trace_input ("jcc", OP_REGP
, OP_VOID
, OP_VOID
);
1300 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1301 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1303 trace_output_32 (sd
, tmp
);
1308 OP_A4_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1311 trace_input ("jhi", OP_REGP
, OP_VOID
, OP_VOID
);
1314 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1315 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1317 trace_output_32 (sd
, tmp
);
1322 OP_A5_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1325 trace_input ("jls", OP_REGP
, OP_VOID
, OP_VOID
);
1328 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1329 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1331 trace_output_32 (sd
, tmp
);
1336 OP_A6_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1339 trace_input ("jgt", OP_REGP
, OP_VOID
, OP_VOID
);
1342 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1343 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1345 trace_output_32 (sd
, tmp
);
1350 OP_A7_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1353 trace_input ("jle", OP_REGP
, OP_VOID
, OP_VOID
);
1356 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1357 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1359 trace_output_32 (sd
, tmp
);
1365 OP_A8_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1368 trace_input ("jfs", OP_REGP
, OP_VOID
, OP_VOID
);
1371 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1372 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1374 trace_output_32 (sd
, tmp
);
1379 OP_A9_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1382 trace_input ("jfc", OP_REGP
, OP_VOID
, OP_VOID
);
1385 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1386 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1388 trace_output_32 (sd
, tmp
);
1393 OP_AA_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1396 trace_input ("jlo", OP_REGP
, OP_VOID
, OP_VOID
);
1397 if (((PSR_Z
) == 0) & ((PSR_L
) == 0))
1399 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1400 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1402 trace_output_32 (sd
, tmp
);
1407 OP_AB_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1410 trace_input ("jhs", OP_REGP
, OP_VOID
, OP_VOID
);
1411 if (((PSR_Z
) == 1) | ((PSR_L
) == 1))
1413 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1414 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1416 trace_output_32 (sd
, tmp
);
1421 OP_AC_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1424 trace_input ("jlt", OP_REGP
, OP_VOID
, OP_VOID
);
1425 if (((PSR_Z
) == 0) & ((PSR_N
) == 0))
1427 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1428 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1430 trace_output_32 (sd
, tmp
);
1435 OP_AD_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1438 trace_input ("jge", OP_REGP
, OP_VOID
, OP_VOID
);
1439 if (((PSR_Z
) == 1) | ((PSR_N
) == 1))
1441 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1442 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1444 trace_output_32 (sd
, tmp
);
1449 OP_AE_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1452 trace_input ("jump", OP_REGP
, OP_VOID
, OP_VOID
);
1453 tmp
= GPR32 (OP
[0]) /*& 0x3fffff*/; /* Use only 0 - 22 bits */
1454 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1455 trace_output_32 (sd
, tmp
);
1460 OP_AF_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1463 trace_input ("jusr", OP_REGP
, OP_VOID
, OP_VOID
);
1464 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1465 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1467 trace_output_32 (sd
, tmp
);
1472 OP_80_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1474 trace_input ("seq", OP_REG
, OP_VOID
, OP_VOID
);
1479 trace_output_void (sd
);
1483 OP_81_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1485 trace_input ("sne", OP_REG
, OP_VOID
, OP_VOID
);
1490 trace_output_void (sd
);
1495 OP_82_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1497 trace_input ("scs", OP_REG
, OP_VOID
, OP_VOID
);
1502 trace_output_void (sd
);
1507 OP_83_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1509 trace_input ("scc", OP_REG
, OP_VOID
, OP_VOID
);
1514 trace_output_void (sd
);
1519 OP_84_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1521 trace_input ("shi", OP_REG
, OP_VOID
, OP_VOID
);
1526 trace_output_void (sd
);
1531 OP_85_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1533 trace_input ("sls", OP_REG
, OP_VOID
, OP_VOID
);
1538 trace_output_void (sd
);
1543 OP_86_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1545 trace_input ("sgt", OP_REG
, OP_VOID
, OP_VOID
);
1550 trace_output_void (sd
);
1555 OP_87_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1557 trace_input ("sle", OP_REG
, OP_VOID
, OP_VOID
);
1562 trace_output_void (sd
);
1567 OP_88_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1569 trace_input ("sfs", OP_REG
, OP_VOID
, OP_VOID
);
1574 trace_output_void (sd
);
1579 OP_89_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1581 trace_input ("sfc", OP_REG
, OP_VOID
, OP_VOID
);
1586 trace_output_void (sd
);
1592 OP_8A_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1594 trace_input ("slo", OP_REG
, OP_VOID
, OP_VOID
);
1595 if (((PSR_Z
) == 0) & ((PSR_L
) == 0))
1599 trace_output_void (sd
);
1604 OP_8B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1606 trace_input ("shs", OP_REG
, OP_VOID
, OP_VOID
);
1607 if ( ((PSR_Z
) == 1) | ((PSR_L
) == 1))
1611 trace_output_void (sd
);
1616 OP_8C_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1618 trace_input ("slt", OP_REG
, OP_VOID
, OP_VOID
);
1619 if (((PSR_Z
) == 0) & ((PSR_N
) == 0))
1623 trace_output_void (sd
);
1628 OP_8D_C (SIM_DESC sd
, SIM_CPU
*cpu
)
1630 trace_input ("sge", OP_REG
, OP_VOID
, OP_VOID
);
1631 if (((PSR_Z
) == 1) | ((PSR_N
) == 1))
1635 trace_output_void (sd
);
1640 OP_D7_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
1642 uint8_t a
= OP
[0] & 0xff;
1643 uint32_t addr
= OP
[1], tmp
;
1644 trace_input ("cbitb", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
1646 SET_PSR_F (tmp
& (1 << a
));
1647 tmp
= tmp
& ~(1 << a
);
1649 trace_output_32 (sd
, tmp
);
1654 OP_107_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
1656 uint8_t a
= OP
[0] & 0xff;
1657 uint32_t addr
= OP
[1], tmp
;
1658 trace_input ("cbitb", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
1660 SET_PSR_F (tmp
& (1 << a
));
1661 tmp
= tmp
& ~(1 << a
);
1663 trace_output_32 (sd
, tmp
);
1668 OP_68_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
1670 uint8_t a
= (OP
[0]) & 0xff;
1671 uint32_t addr
= (GPR (OP
[2])) + OP
[1], tmp
;
1672 trace_input ("cbitb", OP_CONSTANT4
, OP_R_INDEX7_ABS20
, OP_VOID
);
1674 SET_PSR_F (tmp
& (1 << a
));
1675 tmp
= tmp
& ~(1 << a
);
1677 trace_output_32 (sd
, addr
);
1682 OP_1AA_A (SIM_DESC sd
, SIM_CPU
*cpu
)
1684 uint8_t a
= (OP
[0]) & 0xff;
1685 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1686 trace_input ("cbitb", OP_CONSTANT4
, OP_RP_INDEX_DISP14
, OP_VOID
);
1688 SET_PSR_F (tmp
& (1 << a
));
1689 tmp
= tmp
& ~(1 << a
);
1691 trace_output_32 (sd
, addr
);
1696 OP_104_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
1698 uint8_t a
= (OP
[0]) & 0xff;
1699 uint32_t addr
= (GPR (OP
[2])) + OP
[1], tmp
;
1700 trace_input ("cbitb", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
1702 SET_PSR_F (tmp
& (1 << a
));
1703 tmp
= tmp
& ~(1 << a
);
1705 trace_output_32 (sd
, addr
);
1710 OP_D4_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
1712 uint8_t a
= (OP
[0]) & 0xff;
1713 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1714 trace_input ("cbitb", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
1716 SET_PSR_F (tmp
& (1 << a
));
1717 tmp
= tmp
& ~(1 << a
);
1719 trace_output_32 (sd
, addr
);
1724 OP_D6_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
1726 uint8_t a
= (OP
[0]) & 0xff;
1727 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1728 trace_input ("cbitb", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
1730 SET_PSR_F (tmp
& (1 << a
));
1731 tmp
= tmp
& ~(1 << a
);
1733 trace_output_32 (sd
, addr
);
1739 OP_105_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
1741 uint8_t a
= (OP
[0]) & 0xff;
1742 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1743 trace_input ("cbitb", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
1745 SET_PSR_F (tmp
& (1 << a
));
1746 tmp
= tmp
& ~(1 << a
);
1748 trace_output_32 (sd
, addr
);
1753 OP_106_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
1755 uint8_t a
= (OP
[0]) & 0xff;
1756 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1757 trace_input ("cbitb", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
1759 SET_PSR_F (tmp
& (1 << a
));
1760 tmp
= tmp
& ~(1 << a
);
1762 trace_output_32 (sd
, addr
);
1768 OP_6F_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
1771 uint32_t addr
= OP
[1], tmp
;
1772 trace_input ("cbitw", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
1774 SET_PSR_F (tmp
& (1 << a
));
1775 tmp
= tmp
& ~(1 << a
);
1777 trace_output_32 (sd
, tmp
);
1782 OP_117_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
1785 uint32_t addr
= OP
[1], tmp
;
1786 trace_input ("cbitw", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
1788 SET_PSR_F (tmp
& (1 << a
));
1789 tmp
= tmp
& ~(1 << a
);
1791 trace_output_32 (sd
, tmp
);
1796 OP_36_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
1799 uint16_t a
= (OP
[0]), tmp
;
1800 trace_input ("cbitw", OP_CONSTANT4
, OP_R_INDEX8_ABS20
, OP_VOID
);
1803 addr
= (GPR32 (12)) + OP
[2];
1805 addr
= (GPR32 (13)) + OP
[2];
1808 SET_PSR_F (tmp
& (1 << a
));
1809 tmp
= tmp
& ~(1 << a
);
1811 trace_output_32 (sd
, addr
);
1817 OP_1AB_A (SIM_DESC sd
, SIM_CPU
*cpu
)
1819 uint16_t a
= (OP
[0]);
1820 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1821 trace_input ("cbitw", OP_CONSTANT4
, OP_RP_INDEX_DISP14
, OP_VOID
);
1823 SET_PSR_F (tmp
& (1 << a
));
1824 tmp
= tmp
& ~(1 << a
);
1826 trace_output_32 (sd
, addr
);
1831 OP_114_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
1833 uint16_t a
= (OP
[0]);
1834 uint32_t addr
= (GPR (OP
[2])) + OP
[1], tmp
;
1835 trace_input ("cbitw", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
1837 SET_PSR_F (tmp
& (1 << a
));
1838 tmp
= tmp
& ~(1 << a
);
1840 trace_output_32 (sd
, addr
);
1846 OP_6E_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
1848 uint16_t a
= (OP
[0]);
1849 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1850 trace_input ("cbitw", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
1852 SET_PSR_F (tmp
& (1 << a
));
1853 tmp
= tmp
& ~(1 << a
);
1855 trace_output_32 (sd
, addr
);
1860 OP_69_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
1862 uint16_t a
= (OP
[0]);
1863 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1864 trace_input ("cbitw", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
1866 SET_PSR_F (tmp
& (1 << a
));
1867 tmp
= tmp
& ~(1 << a
);
1869 trace_output_32 (sd
, addr
);
1875 OP_115_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
1877 uint16_t a
= (OP
[0]);
1878 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1879 trace_input ("cbitw", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
1881 SET_PSR_F (tmp
& (1 << a
));
1882 tmp
= tmp
& ~(1 << a
);
1884 trace_output_32 (sd
, addr
);
1889 OP_116_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
1891 uint16_t a
= (OP
[0]);
1892 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1893 trace_input ("cbitw", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
1895 SET_PSR_F (tmp
& (1 << a
));
1896 tmp
= tmp
& ~(1 << a
);
1898 trace_output_32 (sd
, addr
);
1903 OP_E7_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
1905 uint8_t a
= OP
[0] & 0xff;
1906 uint32_t addr
= OP
[1], tmp
;
1907 trace_input ("sbitb", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
1909 SET_PSR_F (tmp
& (1 << a
));
1910 tmp
= tmp
| (1 << a
);
1912 trace_output_32 (sd
, tmp
);
1917 OP_10B_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
1919 uint8_t a
= OP
[0] & 0xff;
1920 uint32_t addr
= OP
[1], tmp
;
1921 trace_input ("sbitb", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
1923 SET_PSR_F (tmp
& (1 << a
));
1924 tmp
= tmp
| (1 << a
);
1926 trace_output_32 (sd
, tmp
);
1931 OP_70_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
1933 uint8_t a
= OP
[0] & 0xff;
1934 uint32_t addr
= (GPR (OP
[2])) + OP
[1], tmp
;
1935 trace_input ("sbitb", OP_CONSTANT4
, OP_R_INDEX7_ABS20
, OP_VOID
);
1937 SET_PSR_F (tmp
& (1 << a
));
1938 tmp
= tmp
| (1 << a
);
1940 trace_output_32 (sd
, tmp
);
1945 OP_1CA_A (SIM_DESC sd
, SIM_CPU
*cpu
)
1947 uint8_t a
= OP
[0] & 0xff;
1948 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1949 trace_input ("sbitb", OP_CONSTANT4
, OP_RP_INDEX_DISP14
, OP_VOID
);
1951 SET_PSR_F (tmp
& (1 << a
));
1952 tmp
= tmp
| (1 << a
);
1954 trace_output_32 (sd
, tmp
);
1959 OP_108_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
1961 uint8_t a
= OP
[0] & 0xff;
1962 uint32_t addr
= (GPR (OP
[2])) + OP
[1], tmp
;
1963 trace_input ("sbitb", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
1965 SET_PSR_F (tmp
& (1 << a
));
1966 tmp
= tmp
| (1 << a
);
1968 trace_output_32 (sd
, tmp
);
1974 OP_E4_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
1976 uint8_t a
= OP
[0] & 0xff;
1977 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1978 trace_input ("sbitb", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
1980 SET_PSR_F (tmp
& (1 << a
));
1981 tmp
= tmp
| (1 << a
);
1983 trace_output_32 (sd
, tmp
);
1988 OP_E6_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
1990 uint8_t a
= OP
[0] & 0xff;
1991 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1992 trace_input ("sbitb", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
1994 SET_PSR_F (tmp
& (1 << a
));
1995 tmp
= tmp
| (1 << a
);
1997 trace_output_32 (sd
, tmp
);
2003 OP_109_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2005 uint8_t a
= OP
[0] & 0xff;
2006 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2007 trace_input ("sbitb", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
2009 SET_PSR_F (tmp
& (1 << a
));
2010 tmp
= tmp
| (1 << a
);
2012 trace_output_32 (sd
, tmp
);
2018 OP_10A_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2020 uint8_t a
= OP
[0] & 0xff;
2021 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2022 trace_input ("sbitb", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
2024 SET_PSR_F (tmp
& (1 << a
));
2025 tmp
= tmp
| (1 << a
);
2027 trace_output_32 (sd
, tmp
);
2033 OP_77_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2036 uint32_t addr
= OP
[1], tmp
;
2037 trace_input ("sbitw", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
2039 SET_PSR_F (tmp
& (1 << a
));
2040 tmp
= tmp
| (1 << a
);
2042 trace_output_32 (sd
, tmp
);
2047 OP_11B_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2050 uint32_t addr
= OP
[1], tmp
;
2051 trace_input ("sbitw", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
2053 SET_PSR_F (tmp
& (1 << a
));
2054 tmp
= tmp
| (1 << a
);
2056 trace_output_32 (sd
, tmp
);
2061 OP_3A_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
2064 uint16_t a
= (OP
[0]), tmp
;
2065 trace_input ("sbitw", OP_CONSTANT4
, OP_R_INDEX8_ABS20
, OP_VOID
);
2068 addr
= (GPR32 (12)) + OP
[2];
2070 addr
= (GPR32 (13)) + OP
[2];
2073 SET_PSR_F (tmp
& (1 << a
));
2074 tmp
= tmp
| (1 << a
);
2076 trace_output_32 (sd
, addr
);
2081 OP_1CB_A (SIM_DESC sd
, SIM_CPU
*cpu
)
2083 uint16_t a
= (OP
[0]);
2084 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2085 trace_input ("sbitw", OP_CONSTANT4
, OP_RP_INDEX_DISP14
, OP_VOID
);
2087 SET_PSR_F (tmp
& (1 << a
));
2088 tmp
= tmp
| (1 << a
);
2090 trace_output_32 (sd
, addr
);
2095 OP_118_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2097 uint16_t a
= (OP
[0]);
2098 uint32_t addr
= (GPR (OP
[2])) + OP
[1], tmp
;
2099 trace_input ("sbitw", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
2101 SET_PSR_F (tmp
& (1 << a
));
2102 tmp
= tmp
| (1 << a
);
2104 trace_output_32 (sd
, addr
);
2109 OP_76_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2111 uint16_t a
= (OP
[0]);
2112 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2113 trace_input ("sbitw", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
2115 SET_PSR_F (tmp
& (1 << a
));
2116 tmp
= tmp
| (1 << a
);
2118 trace_output_32 (sd
, addr
);
2123 OP_71_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2125 uint16_t a
= (OP
[0]);
2126 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2127 trace_input ("sbitw", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
2129 SET_PSR_F (tmp
& (1 << a
));
2130 tmp
= tmp
| (1 << a
);
2132 trace_output_32 (sd
, addr
);
2137 OP_119_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2139 uint16_t a
= (OP
[0]);
2140 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2141 trace_input ("sbitw", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
2143 SET_PSR_F (tmp
& (1 << a
));
2144 tmp
= tmp
| (1 << a
);
2146 trace_output_32 (sd
, addr
);
2151 OP_11A_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2153 uint16_t a
= (OP
[0]);
2154 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2155 trace_input ("sbitw", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
2157 SET_PSR_F (tmp
& (1 << a
));
2158 tmp
= tmp
| (1 << a
);
2160 trace_output_32 (sd
, addr
);
2166 OP_F7_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
2168 uint8_t a
= OP
[0] & 0xff;
2169 uint32_t addr
= OP
[1], tmp
;
2170 trace_input ("tbitb", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
2172 SET_PSR_F (tmp
& (1 << a
));
2173 trace_output_32 (sd
, tmp
);
2178 OP_10F_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2180 uint8_t a
= OP
[0] & 0xff;
2181 uint32_t addr
= OP
[1], tmp
;
2182 trace_input ("tbitb", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
2184 SET_PSR_F (tmp
& (1 << a
));
2185 trace_output_32 (sd
, tmp
);
2190 OP_78_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2192 uint8_t a
= (OP
[0]) & 0xff;
2193 uint32_t addr
= (GPR (OP
[2])) + OP
[1], tmp
;
2194 trace_input ("tbitb", OP_CONSTANT4
, OP_R_INDEX7_ABS20
, OP_VOID
);
2196 SET_PSR_F (tmp
& (1 << a
));
2197 trace_output_32 (sd
, addr
);
2202 OP_1EA_A (SIM_DESC sd
, SIM_CPU
*cpu
)
2204 uint8_t a
= (OP
[0]) & 0xff;
2205 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2206 trace_input ("tbitb", OP_CONSTANT4
, OP_RP_INDEX_DISP14
, OP_VOID
);
2208 SET_PSR_F (tmp
& (1 << a
));
2209 trace_output_32 (sd
, addr
);
2214 OP_10C_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2216 uint8_t a
= (OP
[0]) & 0xff;
2217 uint32_t addr
= (GPR (OP
[2])) + OP
[1], tmp
;
2218 trace_input ("tbitb", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
2220 SET_PSR_F (tmp
& (1 << a
));
2221 trace_output_32 (sd
, addr
);
2226 OP_F4_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
2228 uint8_t a
= (OP
[0]) & 0xff;
2229 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2230 trace_input ("tbitb", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
2232 SET_PSR_F (tmp
& (1 << a
));
2233 trace_output_32 (sd
, addr
);
2238 OP_F6_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
2240 uint8_t a
= (OP
[0]) & 0xff;
2241 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2242 trace_input ("tbitb", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
2244 SET_PSR_F (tmp
& (1 << a
));
2245 trace_output_32 (sd
, addr
);
2250 OP_10D_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2252 uint8_t a
= (OP
[0]) & 0xff;
2253 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2254 trace_input ("tbitb", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
2256 SET_PSR_F (tmp
& (1 << a
));
2257 trace_output_32 (sd
, addr
);
2262 OP_10E_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2264 uint8_t a
= (OP
[0]) & 0xff;
2265 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2266 trace_input ("tbitb", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
2268 SET_PSR_F (tmp
& (1 << a
));
2269 trace_output_32 (sd
, addr
);
2275 OP_7F_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2278 uint32_t addr
= OP
[1], tmp
;
2279 trace_input ("tbitw", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
2281 SET_PSR_F (tmp
& (1 << a
));
2282 trace_output_32 (sd
, tmp
);
2287 OP_11F_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2290 uint32_t addr
= OP
[1], tmp
;
2291 trace_input ("tbitw", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
2293 SET_PSR_F (tmp
& (1 << a
));
2294 trace_output_32 (sd
, tmp
);
2300 OP_3E_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
2303 uint16_t a
= (OP
[0]), tmp
;
2304 trace_input ("tbitw", OP_CONSTANT4
, OP_R_INDEX8_ABS20
, OP_VOID
);
2307 addr
= (GPR32 (12)) + OP
[2];
2309 addr
= (GPR32 (13)) + OP
[2];
2312 SET_PSR_F (tmp
& (1 << a
));
2313 trace_output_32 (sd
, addr
);
2318 OP_1EB_A (SIM_DESC sd
, SIM_CPU
*cpu
)
2320 uint16_t a
= (OP
[0]);
2321 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2322 trace_input ("tbitw", OP_CONSTANT4
, OP_RP_INDEX_DISP14
, OP_VOID
);
2324 SET_PSR_F (tmp
& (1 << a
));
2325 trace_output_32 (sd
, addr
);
2330 OP_11C_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2332 uint16_t a
= (OP
[0]);
2333 uint32_t addr
= (GPR (OP
[2])) + OP
[1], tmp
;
2334 trace_input ("tbitw", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
2336 SET_PSR_F (tmp
& (1 << a
));
2337 trace_output_32 (sd
, addr
);
2342 OP_7E_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2344 uint16_t a
= (OP
[0]);
2345 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2346 trace_input ("tbitw", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
2348 SET_PSR_F (tmp
& (1 << a
));
2349 trace_output_32 (sd
, addr
);
2354 OP_79_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2356 uint16_t a
= (OP
[0]);
2357 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2358 trace_input ("tbitw", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
2360 SET_PSR_F (tmp
& (1 << a
));
2361 trace_output_32 (sd
, addr
);
2366 OP_11D_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2368 uint16_t a
= (OP
[0]);
2369 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2370 trace_input ("tbitw", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
2372 SET_PSR_F (tmp
& (1 << a
));
2373 trace_output_32 (sd
, addr
);
2379 OP_11E_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2381 uint16_t a
= (OP
[0]);
2382 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2383 trace_input ("tbitw", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
2385 SET_PSR_F (tmp
& (1 << a
));
2386 trace_output_32 (sd
, addr
);
2392 OP_6_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2395 uint16_t b
= (GPR (OP
[1]));
2396 trace_input ("tbit", OP_CONSTANT4
, OP_REG
, OP_VOID
);
2397 SET_PSR_F (b
& (1 << a
));
2398 trace_output_16 (sd
, b
);
2403 OP_7_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2405 uint16_t a
= GPR (OP
[0]);
2406 uint16_t b
= (GPR (OP
[1]));
2407 trace_input ("tbit", OP_REG
, OP_REG
, OP_VOID
);
2408 SET_PSR_F (b
& (1 << a
));
2409 trace_output_16 (sd
, b
);
2415 OP_50_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2417 uint8_t a
= (OP
[0]) & 0xFF;
2418 uint8_t b
= (GPR (OP
[1])) & 0xFF;
2419 trace_input ("cmpb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
2421 SET_PSR_N ((int8_t)a
> (int8_t)b
);
2423 trace_output_flag (sd
);
2428 OP_50B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
2430 uint8_t a
= (OP
[0]) & 0xFF;
2431 uint8_t b
= (GPR (OP
[1])) & 0xFF;
2432 trace_input ("cmpb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
2434 SET_PSR_N ((int8_t)a
> (int8_t)b
);
2436 trace_output_flag (sd
);
2441 OP_51_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2443 uint8_t a
= (GPR (OP
[0])) & 0xFF;
2444 uint8_t b
= (GPR (OP
[1])) & 0xFF;
2445 trace_input ("cmpb", OP_REG
, OP_REG
, OP_VOID
);
2447 SET_PSR_N ((int8_t)a
> (int8_t)b
);
2449 trace_output_flag (sd
);
2454 OP_52_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2456 uint16_t a
= (OP
[0]);
2457 uint16_t b
= GPR (OP
[1]);
2458 trace_input ("cmpw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
2460 SET_PSR_N ((int16_t)a
> (int16_t)b
);
2462 trace_output_flag (sd
);
2467 OP_52B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
2469 uint16_t a
= (OP
[0]);
2470 uint16_t b
= GPR (OP
[1]);
2471 trace_input ("cmpw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
2473 SET_PSR_N ((int16_t)a
> (int16_t)b
);
2475 trace_output_flag (sd
);
2480 OP_53_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2482 uint16_t a
= GPR (OP
[0]) ;
2483 uint16_t b
= GPR (OP
[1]) ;
2484 trace_input ("cmpw", OP_REG
, OP_REG
, OP_VOID
);
2486 SET_PSR_N ((int16_t)a
> (int16_t)b
);
2488 trace_output_flag (sd
);
2493 OP_56_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2495 uint32_t a
= (OP
[0]);
2496 uint32_t b
= GPR32 (OP
[1]);
2497 trace_input ("cmpd", OP_CONSTANT4
, OP_REGP
, OP_VOID
);
2499 SET_PSR_N ((int32_t)a
> (int32_t)b
);
2501 trace_output_flag (sd
);
2506 OP_56B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
2508 uint32_t a
= (SEXT16(OP
[0]));
2509 uint32_t b
= GPR32 (OP
[1]);
2510 trace_input ("cmpd", OP_CONSTANT16
, OP_REGP
, OP_VOID
);
2512 SET_PSR_N ((int32_t)a
> (int32_t)b
);
2514 trace_output_flag (sd
);
2519 OP_57_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2521 uint32_t a
= GPR32 (OP
[0]) ;
2522 uint32_t b
= GPR32 (OP
[1]) ;
2523 trace_input ("cmpd", OP_REGP
, OP_REGP
, OP_VOID
);
2525 SET_PSR_N ((int32_t)a
> (int32_t)b
);
2527 trace_output_flag (sd
);
2532 OP_9_C (SIM_DESC sd
, SIM_CPU
*cpu
)
2534 uint32_t a
= (OP
[0]);
2535 uint32_t b
= GPR32 (OP
[1]);
2536 trace_input ("cmpd", OP_CONSTANT32
, OP_REGP
, OP_VOID
);
2538 SET_PSR_N ((int32_t)a
> (int32_t)b
);
2540 trace_output_flag (sd
);
2546 OP_58_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2548 uint8_t tmp
= OP
[0] & 0xFF;
2549 uint16_t a
= (GPR (OP
[1])) & 0xFF00;
2550 trace_input ("movb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
2551 SET_GPR (OP
[1], (a
| tmp
));
2552 trace_output_16 (sd
, tmp
);
2557 OP_58B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
2559 uint8_t tmp
= OP
[0] & 0xFF;
2560 uint16_t a
= (GPR (OP
[1])) & 0xFF00;
2561 trace_input ("movb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
2562 SET_GPR (OP
[1], (a
| tmp
));
2563 trace_output_16 (sd
, tmp
);
2568 OP_59_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2570 uint8_t tmp
= (GPR (OP
[0])) & 0xFF;
2571 uint16_t a
= (GPR (OP
[1])) & 0xFF00;
2572 trace_input ("movb", OP_REG
, OP_REG
, OP_VOID
);
2573 SET_GPR (OP
[1], (a
| tmp
));
2574 trace_output_16 (sd
, tmp
);
2579 OP_5A_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2581 uint16_t tmp
= OP
[0];
2582 trace_input ("movw", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
2583 SET_GPR (OP
[1], (tmp
& 0xffff));
2584 trace_output_16 (sd
, tmp
);
2589 OP_5AB_C (SIM_DESC sd
, SIM_CPU
*cpu
)
2591 int16_t tmp
= OP
[0];
2592 trace_input ("movw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
2593 SET_GPR (OP
[1], (tmp
& 0xffff));
2594 trace_output_16 (sd
, tmp
);
2599 OP_5B_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2601 uint16_t tmp
= GPR (OP
[0]);
2602 uint32_t a
= GPR32 (OP
[1]);
2603 trace_input ("movw", OP_REG
, OP_REGP
, OP_VOID
);
2604 a
= (a
& 0xffff0000) | tmp
;
2605 SET_GPR32 (OP
[1], a
);
2606 trace_output_16 (sd
, tmp
);
2611 OP_5C_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2613 uint8_t tmp
= (GPR (OP
[0])) & 0xFF;
2614 trace_input ("movxb", OP_REG
, OP_REG
, OP_VOID
);
2615 SET_GPR (OP
[1], ((SEXT8(tmp
)) & 0xffff));
2616 trace_output_16 (sd
, tmp
);
2621 OP_5D_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2623 uint8_t tmp
= (GPR (OP
[0])) & 0xFF;
2624 trace_input ("movzb", OP_REG
, OP_REG
, OP_VOID
);
2625 SET_GPR (OP
[1], tmp
);
2626 trace_output_16 (sd
, tmp
);
2631 OP_5E_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2633 uint16_t tmp
= GPR (OP
[0]);
2634 trace_input ("movxw", OP_REG
, OP_REGP
, OP_VOID
);
2635 SET_GPR32 (OP
[1], SEXT16(tmp
));
2636 trace_output_16 (sd
, tmp
);
2641 OP_5F_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2643 uint16_t tmp
= GPR (OP
[0]);
2644 trace_input ("movzw", OP_REG
, OP_REGP
, OP_VOID
);
2645 SET_GPR32 (OP
[1], (tmp
& 0x0000FFFF));
2646 trace_output_16 (sd
, tmp
);
2651 OP_54_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2653 int32_t tmp
= OP
[0];
2654 trace_input ("movd", OP_CONSTANT4
, OP_REGP
, OP_VOID
);
2655 SET_GPR32 (OP
[1], tmp
);
2656 trace_output_32 (sd
, tmp
);
2661 OP_54B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
2663 int32_t tmp
= SEXT16(OP
[0]);
2664 trace_input ("movd", OP_CONSTANT16
, OP_REGP
, OP_VOID
);
2665 SET_GPR32 (OP
[1], tmp
);
2666 trace_output_32 (sd
, tmp
);
2671 OP_55_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2673 uint32_t tmp
= GPR32 (OP
[0]);
2674 trace_input ("movd", OP_REGP
, OP_REGP
, OP_VOID
);
2675 SET_GPR32 (OP
[1], tmp
);
2676 trace_output_32 (sd
, tmp
);
2681 OP_5_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2683 uint32_t tmp
= OP
[0];
2684 trace_input ("movd", OP_CONSTANT20
, OP_REGP
, OP_VOID
);
2685 SET_GPR32 (OP
[1], tmp
);
2686 trace_output_32 (sd
, tmp
);
2691 OP_7_C (SIM_DESC sd
, SIM_CPU
*cpu
)
2693 int32_t tmp
= OP
[0];
2694 trace_input ("movd", OP_CONSTANT32
, OP_REGP
, OP_VOID
);
2695 SET_GPR32 (OP
[1], tmp
);
2696 trace_output_32 (sd
, tmp
);
2701 OP_14_D (SIM_DESC sd
, SIM_CPU
*cpu
)
2703 uint32_t addr
= GPR (0);
2704 uint16_t count
= OP
[0], reg
= 2, tmp
;
2705 trace_input ("loadm", OP_CONSTANT4
, OP_VOID
, OP_VOID
);
2708 trace_output_void (sd
);
2709 EXCEPTION (SIM_SIGBUS
);
2719 if (reg
== 6) reg
= 8;
2723 trace_output_void (sd
);
2729 OP_15_D (SIM_DESC sd
, SIM_CPU
*cpu
)
2731 uint32_t addr
= GPR32 (0);
2732 uint16_t count
= OP
[0], reg
= 2, tmp
;
2733 trace_input ("loadm", OP_CONSTANT4
, OP_VOID
, OP_VOID
);
2736 trace_output_void (sd
);
2737 EXCEPTION (SIM_SIGBUS
);
2747 if (reg
== 6) reg
= 8;
2750 SET_GPR32 (0, addr
);
2751 trace_output_void (sd
);
2757 OP_88_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2760 * ADDR = zext24(abs20) | remap (ie 0xF00000)
2763 * If (abs20 > 0xEFFFF) the resulting address is logically ORed
2764 * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
2765 * by the core to 16M-64k to 16M. */
2767 uint16_t tmp
, a
= (GPR (OP
[1])) & 0xFF00;
2768 uint32_t addr
= OP
[0];
2769 trace_input ("loadb", OP_ABS20
, OP_REG
, OP_VOID
);
2770 if (addr
> 0xEFFFF) addr
|= 0xF00000;
2772 SET_GPR (OP
[1], (a
| tmp
));
2773 trace_output_16 (sd
, tmp
);
2778 OP_127_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2784 uint16_t tmp
, a
= (GPR (OP
[1])) & 0xFF00;
2785 uint32_t addr
= OP
[0];
2786 trace_input ("loadb", OP_ABS24
, OP_REG
, OP_VOID
);
2788 SET_GPR (OP
[1], (a
| tmp
));
2789 trace_output_16 (sd
, tmp
);
2794 OP_45_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
2796 /* loadb [Rindex]ABS20 REG
2797 * ADDR = Rindex + zext24(disp20)
2801 uint16_t tmp
, a
= (GPR (OP
[2])) & 0xFF00;
2802 trace_input ("loadb", OP_R_INDEX8_ABS20
, OP_REG
, OP_VOID
);
2805 addr
= (GPR32 (12)) + OP
[1];
2807 addr
= (GPR32 (13)) + OP
[1];
2810 SET_GPR (OP
[2], (a
| tmp
));
2811 trace_output_16 (sd
, tmp
);
2817 OP_B_4 (SIM_DESC sd
, SIM_CPU
*cpu
)
2819 /* loadb DIPS4(REGP) REG
2820 * ADDR = RPBASE + zext24(DISP4)
2822 uint16_t tmp
, a
= (GPR (OP
[2])) & 0xFF00;
2823 uint32_t addr
= (GPR32 (OP
[1])) + OP
[0];
2824 trace_input ("loadb", OP_RP_BASE_DISP4
, OP_REG
, OP_VOID
);
2826 SET_GPR (OP
[2], (a
| tmp
));
2827 trace_output_16 (sd
, tmp
);
2832 OP_BE_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2834 /* loadb [Rindex]disp0(RPbasex) REG
2835 * ADDR = Rpbasex + Rindex
2839 uint16_t tmp
, a
= (GPR (OP
[3])) & 0xFF00;
2840 trace_input ("loadb", OP_RP_INDEX_DISP0
, OP_REG
, OP_VOID
);
2842 addr
= (GPR32 (OP
[2])) + OP
[1];
2845 addr
= (GPR32 (12)) + addr
;
2847 addr
= (GPR32 (13)) + addr
;
2850 SET_GPR (OP
[3], (a
| tmp
));
2851 trace_output_16 (sd
, tmp
);
2856 OP_219_A (SIM_DESC sd
, SIM_CPU
*cpu
)
2858 /* loadb [Rindex]disp14(RPbasex) REG
2859 * ADDR = Rpbasex + Rindex + zext24(disp14)
2863 uint16_t tmp
, a
= (GPR (OP
[3])) & 0xFF00;
2865 addr
= (GPR32 (OP
[2])) + OP
[1];
2868 addr
= (GPR32 (12)) + addr
;
2870 addr
= (GPR32 (13)) + addr
;
2872 trace_input ("loadb", OP_RP_INDEX_DISP14
, OP_REG
, OP_VOID
);
2874 SET_GPR (OP
[3], (a
| tmp
));
2875 trace_output_16 (sd
, tmp
);
2881 OP_184_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2883 /* loadb DISPE20(REG) REG
2884 * zext24(Rbase) + zext24(dispe20)
2887 uint16_t tmp
,a
= (GPR (OP
[2])) & 0xFF00;
2888 uint32_t addr
= OP
[0] + (GPR (OP
[1]));
2889 trace_input ("loadb", OP_R_BASE_DISPE20
, OP_REG
, OP_VOID
);
2891 SET_GPR (OP
[2], (a
| tmp
));
2892 trace_output_16 (sd
, tmp
);
2897 OP_124_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2899 /* loadb DISP20(REG) REG
2900 * ADDR = zext24(Rbase) + zext24(disp20)
2903 uint16_t tmp
,a
= (GPR (OP
[2])) & 0xFF00;
2904 uint32_t addr
= OP
[0] + (GPR (OP
[1]));
2905 trace_input ("loadb", OP_R_BASE_DISP20
, OP_REG
, OP_VOID
);
2907 SET_GPR (OP
[2], (a
| tmp
));
2908 trace_output_16 (sd
, tmp
);
2913 OP_BF_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2915 /* loadb disp16(REGP) REG
2916 * ADDR = RPbase + zext24(disp16)
2919 uint16_t tmp
,a
= (GPR (OP
[2])) & 0xFF00;
2920 uint32_t addr
= (GPR32 (OP
[1])) + OP
[0];
2921 trace_input ("loadb", OP_RP_BASE_DISP16
, OP_REG
, OP_VOID
);
2923 SET_GPR (OP
[2], (a
| tmp
));
2924 trace_output_16 (sd
, tmp
);
2929 OP_125_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2931 /* loadb disp20(REGP) REG
2932 * ADDR = RPbase + zext24(disp20)
2934 uint16_t tmp
,a
= (GPR (OP
[2])) & 0xFF00;
2935 uint32_t addr
= (GPR32 (OP
[1])) + OP
[0];
2936 trace_input ("loadb", OP_RP_BASE_DISP20
, OP_REG
, OP_VOID
);
2938 SET_GPR (OP
[2], (a
| tmp
));
2939 trace_output_16 (sd
, tmp
);
2945 OP_185_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2947 /* loadb -disp20(REGP) REG
2948 * ADDR = RPbase + zext24(-disp20)
2950 uint16_t tmp
,a
= (GPR (OP
[2])) & 0xFF00;
2951 uint32_t addr
= (GPR32 (OP
[1])) + OP
[1];
2952 trace_input ("loadb", OP_RP_BASE_DISPE20
, OP_REG
, OP_VOID
);
2954 SET_GPR (OP
[2], (a
| tmp
));
2955 trace_output_16 (sd
, tmp
);
2960 OP_126_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
2962 /* loadb [Rindex]disp20(RPbasexb) REG
2963 * ADDR = RPbasex + Rindex + zext24(disp20)
2967 uint16_t tmp
, a
= (GPR (OP
[3])) & 0xFF00;
2968 trace_input ("loadb", OP_RP_INDEX_DISP20
, OP_REG
, OP_VOID
);
2970 addr
= (GPR32 (OP
[2])) + OP
[1];
2973 addr
= (GPR32 (12)) + addr
;
2975 addr
= (GPR32 (13)) + addr
;
2978 SET_GPR (OP
[3], (a
| tmp
));
2979 trace_output_16 (sd
, tmp
);
2985 OP_89_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
2988 * ADDR = zext24(abs20) | remap
2991 * If (abs20 > 0xEFFFF) the resulting address is logically ORed
2992 * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
2993 * by the core to 16M-64k to 16M. */
2996 uint32_t addr
= OP
[0];
2997 trace_input ("loadw", OP_ABS20
, OP_REG
, OP_VOID
);
2998 if (addr
> 0xEFFFF) addr
|= 0xF00000;
3000 SET_GPR (OP
[1], tmp
);
3001 trace_output_16 (sd
, tmp
);
3007 OP_12F_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3013 uint32_t addr
= OP
[0];
3014 trace_input ("loadw", OP_ABS24
, OP_REG
, OP_VOID
);
3016 SET_GPR (OP
[1], tmp
);
3017 trace_output_16 (sd
, tmp
);
3022 OP_47_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
3024 /* loadw [Rindex]ABS20 REG
3025 * ADDR = Rindex + zext24(disp20)
3030 trace_input ("loadw", OP_R_INDEX8_ABS20
, OP_REG
, OP_VOID
);
3033 addr
= (GPR32 (12)) + OP
[1];
3035 addr
= (GPR32 (13)) + OP
[1];
3038 SET_GPR (OP
[2], tmp
);
3039 trace_output_16 (sd
, tmp
);
3045 OP_9_4 (SIM_DESC sd
, SIM_CPU
*cpu
)
3047 /* loadw DIPS4(REGP) REGP
3048 * ADDR = RPBASE + zext24(DISP4)
3052 trace_input ("loadw", OP_RP_BASE_DISP4
, OP_REG
, OP_VOID
);
3053 addr
= (GPR32 (OP
[1])) + OP
[0];
3057 a
= (GPR32 (OP
[2])) & 0xffff0000;
3058 SET_GPR32 (OP
[2], (a
| tmp
));
3061 SET_GPR (OP
[2], tmp
);
3063 trace_output_16 (sd
, tmp
);
3069 OP_9E_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3071 /* loadw [Rindex]disp0(RPbasex) REG
3072 * ADDR = Rpbasex + Rindex
3077 trace_input ("loadw", OP_RP_INDEX_DISP0
, OP_REG
, OP_VOID
);
3079 addr
= (GPR32 (OP
[2])) + OP
[1];
3082 addr
= (GPR32 (12)) + addr
;
3084 addr
= (GPR32 (13)) + addr
;
3087 SET_GPR (OP
[3], tmp
);
3088 trace_output_16 (sd
, tmp
);
3094 OP_21B_A (SIM_DESC sd
, SIM_CPU
*cpu
)
3096 /* loadw [Rindex]disp14(RPbasex) REG
3097 * ADDR = Rpbasex + Rindex + zext24(disp14)
3102 trace_input ("loadw", OP_RP_INDEX_DISP14
, OP_REG
, OP_VOID
);
3103 addr
= (GPR32 (OP
[2])) + OP
[1];
3106 addr
= (GPR32 (12)) + addr
;
3108 addr
= (GPR32 (13)) + addr
;
3111 SET_GPR (OP
[3], tmp
);
3112 trace_output_16 (sd
, tmp
);
3117 OP_18C_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3119 /* loadw dispe20(REG) REGP
3120 * REGP = [DISPE20+[REG]] */
3124 trace_input ("loadw", OP_R_BASE_DISPE20
, OP_REGP
, OP_VOID
);
3125 addr
= OP
[0] + (GPR (OP
[1]));
3129 a
= (GPR32 (OP
[2])) & 0xffff0000;
3130 SET_GPR32 (OP
[2], (a
| tmp
));
3133 SET_GPR (OP
[2], tmp
);
3135 trace_output_16 (sd
, tmp
);
3141 OP_12C_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3143 /* loadw DISP20(REG) REGP
3144 * ADDR = zext24(Rbase) + zext24(disp20)
3149 trace_input ("loadw", OP_R_BASE_DISP20
, OP_REGP
, OP_VOID
);
3150 addr
= OP
[0] + (GPR (OP
[1]));
3154 a
= (GPR32 (OP
[2])) & 0xffff0000;
3155 SET_GPR32 (OP
[2], (a
| tmp
));
3158 SET_GPR (OP
[2], tmp
);
3160 trace_output_16 (sd
, tmp
);
3165 OP_9F_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3167 /* loadw disp16(REGP) REGP
3168 * ADDR = RPbase + zext24(disp16)
3172 trace_input ("loadw", OP_RP_BASE_DISP16
, OP_REGP
, OP_VOID
);
3173 addr
= (GPR32 (OP
[1])) + OP
[0];
3177 a
= (GPR32 (OP
[2])) & 0xffff0000;
3178 SET_GPR32 (OP
[2], (a
| tmp
));
3181 SET_GPR (OP
[2], tmp
);
3183 trace_output_16 (sd
, tmp
);
3188 OP_12D_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3190 /* loadw disp20(REGP) REGP
3191 * ADDR = RPbase + zext24(disp20)
3195 trace_input ("loadw", OP_RP_BASE_DISP20
, OP_REG
, OP_VOID
);
3196 addr
= (GPR32 (OP
[1])) + OP
[0];
3200 a
= (GPR32 (OP
[2])) & 0xffff0000;
3201 SET_GPR32 (OP
[2], (a
| tmp
));
3204 SET_GPR (OP
[2], tmp
);
3206 trace_output_16 (sd
, tmp
);
3211 OP_18D_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3213 /* loadw -disp20(REGP) REG
3214 * ADDR = RPbase + zext24(-disp20)
3219 trace_input ("loadw", OP_RP_BASE_DISPE20
, OP_REG
, OP_VOID
);
3220 addr
= (GPR32 (OP
[1])) + OP
[0];
3224 a
= (GPR32 (OP
[2])) & 0xffff0000;
3225 SET_GPR32 (OP
[2], (a
| tmp
));
3228 SET_GPR (OP
[2], tmp
);
3230 trace_output_16 (sd
, tmp
);
3236 OP_12E_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3238 /* loadw [Rindex]disp20(RPbasexb) REG
3239 * ADDR = RPbasex + Rindex + zext24(disp20)
3244 trace_input ("loadw", OP_RP_INDEX_DISP20
, OP_REG
, OP_VOID
);
3247 addr
= (GPR32 (12)) + OP
[1] + (GPR32 (OP
[2]));
3249 addr
= (GPR32 (13)) + OP
[1] + (GPR32 (OP
[2]));
3252 SET_GPR (OP
[3], tmp
);
3253 trace_output_16 (sd
, tmp
);
3259 OP_87_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3261 /* loadd ABS20, REGP
3262 * ADDR = zext24(abs20) | remap
3265 * If (abs20 > 0xEFFFF) the resulting address is logically ORed
3266 * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
3267 * by the core to 16M-64k to 16M. */
3271 trace_input ("loadd", OP_ABS20
, OP_REGP
, OP_VOID
);
3272 if (addr
> 0xEFFFF) addr
|= 0xF00000;
3274 tmp
= ((tmp
<< 16) & 0xffff)| ((tmp
>> 16) & 0xffff);
3275 SET_GPR32 (OP
[1], tmp
);
3276 trace_output_32 (sd
, tmp
);
3281 OP_12B_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3283 /* loadd ABS24, REGP
3287 uint32_t addr
= OP
[0];
3289 trace_input ("loadd", OP_ABS24
, OP_REGP
, OP_VOID
);
3291 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3292 SET_GPR32 (OP
[1],tmp
);
3293 trace_output_32 (sd
, tmp
);
3299 OP_46_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
3301 /* loadd [Rindex]ABS20 REGP
3302 * ADDR = Rindex + zext24(disp20)
3306 trace_input ("loadd", OP_R_INDEX8_ABS20
, OP_REGP
, OP_VOID
);
3309 addr
= (GPR32 (12)) + OP
[1];
3311 addr
= (GPR32 (13)) + OP
[1];
3314 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3315 SET_GPR32 (OP
[2], tmp
);
3316 trace_output_32 (sd
, tmp
);
3322 OP_A_4 (SIM_DESC sd
, SIM_CPU
*cpu
)
3324 /* loadd dips4(regp) REGP
3325 * ADDR = Rpbase + zext24(disp4)
3328 uint32_t tmp
, addr
= (GPR32 (OP
[1])) + OP
[0];
3329 trace_input ("loadd", OP_RP_BASE_DISP4
, OP_REGP
, OP_VOID
);
3331 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3332 SET_GPR32 (OP
[2], tmp
);
3333 trace_output_32 (sd
, tmp
);
3339 OP_AE_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3341 /* loadd [Rindex]disp0(RPbasex) REGP
3342 * ADDR = Rpbasex + Rindex
3346 trace_input ("loadd", OP_RP_INDEX_DISP0
, OP_REGP
, OP_VOID
);
3349 addr
= (GPR32 (12)) + (GPR32 (OP
[2])) + OP
[1];
3351 addr
= (GPR32 (13)) + (GPR32 (OP
[2])) + OP
[1];
3354 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3355 SET_GPR32 (OP
[3], tmp
);
3356 trace_output_32 (sd
, tmp
);
3362 OP_21A_A (SIM_DESC sd
, SIM_CPU
*cpu
)
3364 /* loadd [Rindex]disp14(RPbasex) REGP
3365 * ADDR = Rpbasex + Rindex + zext24(disp14)
3369 trace_input ("loadd", OP_RP_INDEX_DISP14
, OP_REGP
, OP_VOID
);
3372 addr
= (GPR32 (12)) + OP
[1] + (GPR32 (OP
[2]));
3374 addr
= (GPR32 (13)) + OP
[1] + (GPR32 (OP
[2]));
3377 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3378 SET_GPR (OP
[3],tmp
);
3379 trace_output_32 (sd
, tmp
);
3385 OP_188_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3387 /* loadd dispe20(REG) REG
3388 * zext24(Rbase) + zext24(dispe20)
3391 uint32_t tmp
, addr
= OP
[0] + (GPR (OP
[1]));
3392 trace_input ("loadd", OP_R_BASE_DISPE20
, OP_REGP
, OP_VOID
);
3394 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3395 SET_GPR32 (OP
[2], tmp
);
3396 trace_output_32 (sd
, tmp
);
3402 OP_128_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3404 /* loadd DISP20(REG) REG
3405 * ADDR = zext24(Rbase) + zext24(disp20)
3408 uint32_t tmp
, addr
= OP
[0] + (GPR (OP
[1]));
3409 trace_input ("loadd", OP_R_BASE_DISP20
, OP_REGP
, OP_VOID
);
3411 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3412 SET_GPR32 (OP
[2], tmp
);
3413 trace_output_32 (sd
, tmp
);
3418 OP_AF_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3420 /* loadd disp16(REGP) REGP
3421 * ADDR = RPbase + zext24(disp16)
3423 uint32_t tmp
, addr
= OP
[0] + (GPR32 (OP
[1]));
3424 trace_input ("loadd", OP_RP_BASE_DISP16
, OP_REGP
, OP_VOID
);
3426 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3427 SET_GPR32 (OP
[2], tmp
);
3428 trace_output_32 (sd
, tmp
);
3434 OP_129_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3436 /* loadd disp20(REGP) REGP
3437 * ADDR = RPbase + zext24(disp20)
3439 uint32_t tmp
, addr
= OP
[0] + (GPR32 (OP
[1]));
3440 trace_input ("loadd", OP_RP_BASE_DISP20
, OP_REGP
, OP_VOID
);
3442 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3443 SET_GPR32 (OP
[2], tmp
);
3444 trace_output_32 (sd
, tmp
);
3449 OP_189_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3451 /* loadd -disp20(REGP) REGP
3452 * ADDR = RPbase + zext24(-disp20)
3455 uint32_t tmp
, addr
= OP
[0] + (GPR32 (OP
[1]));
3456 trace_input ("loadd", OP_RP_BASE_DISPE20
, OP_REGP
, OP_VOID
);
3458 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3459 SET_GPR32 (OP
[2], tmp
);
3460 trace_output_32 (sd
, tmp
);
3465 OP_12A_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3467 /* loadd [Rindex]disp20(RPbasexb) REGP
3468 * ADDR = RPbasex + Rindex + zext24(disp20)
3472 trace_input ("loadd", OP_RP_INDEX_DISP20
, OP_REGP
, OP_VOID
);
3475 addr
= (GPR32 (12)) + OP
[1] + (GPR32 (OP
[2]));
3477 addr
= (GPR32 (13)) + OP
[1] + (GPR32 (OP
[2]));
3480 tmp
= ((tmp
<< 16) & 0xffff)| ((tmp
>> 16) & 0xffff);
3481 SET_GPR32 (OP
[3], tmp
);
3482 trace_output_32 (sd
, tmp
);
3488 OP_C8_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3491 * ADDR = zext24(abs20) | remap
3494 * If (abs20 > 0xEFFFF) the resulting address is logically ORed
3495 * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
3496 * by the core to 16M-64k to 16M. */
3498 uint8_t a
= ((GPR (OP
[0])) & 0xff);
3499 uint32_t addr
= OP
[1];
3500 trace_input ("storb", OP_REG
, OP_ABS20_OUTPUT
, OP_VOID
);
3502 trace_output_32 (sd
, addr
);
3507 OP_137_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3513 uint8_t a
= ((GPR (OP
[0])) & 0xff);
3514 uint32_t addr
= OP
[1];
3515 trace_input ("storb", OP_REG
, OP_ABS24_OUTPUT
, OP_VOID
);
3517 trace_output_32 (sd
, addr
);
3522 OP_65_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
3524 /* storb REG, [Rindex]ABS20
3525 * ADDR = Rindex + zext24(disp20)
3529 uint8_t a
= ((GPR (OP
[0])) & 0xff);
3530 trace_input ("storb", OP_REG
, OP_R_INDEX8_ABS20
, OP_VOID
);
3533 addr
= (GPR32 (12)) + OP
[2];
3535 addr
= (GPR32 (13)) + OP
[2];
3538 trace_output_32 (sd
, addr
);
3543 OP_F_4 (SIM_DESC sd
, SIM_CPU
*cpu
)
3545 /* storb REG, DIPS4(REGP)
3546 * ADDR = RPBASE + zext24(DISP4)
3549 uint16_t a
= ((GPR (OP
[0])) & 0xff);
3550 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3551 trace_input ("storb", OP_REG
, OP_RP_BASE_DISPE4
, OP_VOID
);
3553 trace_output_32 (sd
, addr
);
3558 OP_FE_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3560 /* storb [Rindex]disp0(RPbasex) REG
3561 * ADDR = Rpbasex + Rindex
3565 uint8_t a
= ((GPR (OP
[0])) & 0xff);
3566 trace_input ("storb", OP_REG
, OP_RP_INDEX_DISP0
, OP_VOID
);
3569 addr
= (GPR32 (12)) + (GPR32 (OP
[3])) + OP
[2];
3571 addr
= (GPR32 (13)) + (GPR32 (OP
[3])) + OP
[2];
3574 trace_output_32 (sd
, addr
);
3579 OP_319_A (SIM_DESC sd
, SIM_CPU
*cpu
)
3581 /* storb REG, [Rindex]disp14(RPbasex)
3582 * ADDR = Rpbasex + Rindex + zext24(disp14)
3585 uint8_t a
= ((GPR (OP
[0])) & 0xff);
3586 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3587 trace_input ("storb", OP_REG
, OP_RP_INDEX_DISP14
, OP_VOID
);
3589 trace_output_32 (sd
, addr
);
3594 OP_194_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3596 /* storb REG, DISPE20(REG)
3597 * zext24(Rbase) + zext24(dispe20)
3600 uint8_t a
= ((GPR (OP
[0])) & 0xff);
3601 uint32_t addr
= OP
[1] + (GPR (OP
[2]));
3602 trace_input ("storb", OP_REG
, OP_R_BASE_DISPE20
, OP_VOID
);
3604 trace_output_32 (sd
, addr
);
3609 OP_134_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3611 /* storb REG, DISP20(REG)
3612 * ADDR = zext24(Rbase) + zext24(disp20)
3615 uint8_t a
= (GPR (OP
[0]) & 0xff);
3616 uint32_t addr
= OP
[1] + (GPR (OP
[2]));
3617 trace_input ("storb", OP_REG
, OP_R_BASE_DISPS20
, OP_VOID
);
3619 trace_output_32 (sd
, addr
);
3624 OP_FF_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3626 /* storb REG, disp16(REGP)
3627 * ADDR = RPbase + zext24(disp16)
3630 uint8_t a
= ((GPR (OP
[0])) & 0xff);
3631 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3632 trace_input ("storb", OP_REG
, OP_RP_BASE_DISP16
, OP_VOID
);
3634 trace_output_32 (sd
, addr
);
3639 OP_135_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3641 /* storb REG, disp20(REGP)
3642 * ADDR = RPbase + zext24(disp20)
3645 uint8_t a
= ((GPR (OP
[0])) & 0xff);
3646 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3647 trace_input ("storb", OP_REG
, OP_RP_BASE_DISPS20
, OP_VOID
);
3649 trace_output_32 (sd
, addr
);
3654 OP_195_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3656 /* storb REG, -disp20(REGP)
3657 * ADDR = RPbase + zext24(-disp20)
3660 uint8_t a
= (GPR (OP
[0]) & 0xff);
3661 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3662 trace_input ("storb", OP_REG
, OP_RP_BASE_DISPE20
, OP_VOID
);
3664 trace_output_32 (sd
, addr
);
3669 OP_136_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3671 /* storb REG, [Rindex]disp20(RPbase)
3672 * ADDR = RPbasex + Rindex + zext24(disp20)
3675 uint8_t a
= (GPR (OP
[0])) & 0xff;
3676 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3677 trace_input ("storb", OP_REG
, OP_RP_INDEX_DISPS20
, OP_VOID
);
3679 trace_output_32 (sd
, addr
);
3682 /* STR_IMM instructions. */
3685 OP_81_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3687 uint8_t a
= (OP
[0]) & 0xff;
3688 uint32_t addr
= OP
[1];
3689 trace_input ("storb", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
3691 trace_output_32 (sd
, addr
);
3696 OP_123_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3698 uint8_t a
= (OP
[0]) & 0xff;
3699 uint32_t addr
= OP
[1];
3700 trace_input ("storb", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
3702 trace_output_32 (sd
, addr
);
3707 OP_42_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
3710 uint8_t a
= (OP
[0]) & 0xff;
3711 trace_input ("storb", OP_CONSTANT4
, OP_R_INDEX8_ABS20
, OP_VOID
);
3714 addr
= (GPR32 (12)) + OP
[2];
3716 addr
= (GPR32 (13)) + OP
[2];
3719 trace_output_32 (sd
, addr
);
3724 OP_218_A (SIM_DESC sd
, SIM_CPU
*cpu
)
3726 uint8_t a
= (OP
[0]) & 0xff;
3727 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3728 trace_input ("storb", OP_CONSTANT4
, OP_RP_BASE_DISP14
, OP_VOID
);
3730 trace_output_32 (sd
, addr
);
3735 OP_82_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3737 uint8_t a
= (OP
[0]) & 0xff;
3738 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3739 trace_input ("storb", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
3741 trace_output_32 (sd
, addr
);
3746 OP_120_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3748 uint8_t a
= (OP
[0]) & 0xff;
3749 uint32_t addr
= (GPR (OP
[2])) + OP
[1];
3750 trace_input ("storb", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
3752 trace_output_32 (sd
, addr
);
3757 OP_83_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3759 uint8_t a
= (OP
[0]) & 0xff;
3760 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3761 trace_input ("storb", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
3763 trace_output_32 (sd
, addr
);
3768 OP_121_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3770 uint8_t a
= (OP
[0]) & 0xff;
3771 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3772 trace_input ("storb", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
3774 trace_output_32 (sd
, addr
);
3779 OP_122_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3781 uint8_t a
= (OP
[0]) & 0xff;
3782 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3783 trace_input ("storb", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
3785 trace_output_32 (sd
, addr
);
3787 /* endif for STR_IMM. */
3791 OP_C9_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3793 uint16_t a
= GPR (OP
[0]);
3794 uint32_t addr
= OP
[1];
3795 trace_input ("storw", OP_REG
, OP_ABS20_OUTPUT
, OP_VOID
);
3797 trace_output_32 (sd
, addr
);
3802 OP_13F_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3804 uint16_t a
= GPR (OP
[0]);
3805 uint32_t addr
= OP
[1];
3806 trace_input ("storw", OP_REG
, OP_ABS24_OUTPUT
, OP_VOID
);
3808 trace_output_32 (sd
, addr
);
3813 OP_67_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
3816 uint16_t a
= GPR (OP
[0]);
3817 trace_input ("storw", OP_REG
, OP_R_INDEX8_ABS20
, OP_VOID
);
3820 addr
= (GPR32 (12)) + OP
[2];
3822 addr
= (GPR32 (13)) + OP
[2];
3825 trace_output_32 (sd
, addr
);
3831 OP_D_4 (SIM_DESC sd
, SIM_CPU
*cpu
)
3833 uint16_t a
= (GPR (OP
[0]));
3834 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3835 trace_input ("storw", OP_REGP
, OP_RP_BASE_DISPE4
, OP_VOID
);
3837 trace_output_32 (sd
, addr
);
3842 OP_DE_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3844 uint16_t a
= GPR (OP
[0]);
3845 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3846 trace_input ("storw", OP_REG
, OP_RP_INDEX_DISP0
, OP_VOID
);
3848 trace_output_32 (sd
, addr
);
3853 OP_31B_A (SIM_DESC sd
, SIM_CPU
*cpu
)
3855 uint16_t a
= GPR (OP
[0]);
3856 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3857 trace_input ("storw", OP_REG
, OP_RP_INDEX_DISP14
, OP_VOID
);
3859 trace_output_32 (sd
, addr
);
3864 OP_19C_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3866 uint16_t a
= (GPR (OP
[0]));
3867 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3868 trace_input ("storw", OP_REGP
, OP_RP_BASE_DISPE20
, OP_VOID
);
3870 trace_output_32 (sd
, addr
);
3875 OP_13C_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3877 uint16_t a
= (GPR (OP
[0]));
3878 uint32_t addr
= (GPR (OP
[2])) + OP
[1];
3879 trace_input ("storw", OP_REG
, OP_R_BASE_DISPS20
, OP_VOID
);
3881 trace_output_32 (sd
, addr
);
3886 OP_DF_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3888 uint16_t a
= (GPR (OP
[0]));
3889 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3890 trace_input ("storw", OP_REG
, OP_RP_BASE_DISP16
, OP_VOID
);
3892 trace_output_32 (sd
, addr
);
3897 OP_13D_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3899 uint16_t a
= (GPR (OP
[0]));
3900 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3901 trace_input ("storw", OP_REG
, OP_RP_BASE_DISPS20
, OP_VOID
);
3903 trace_output_32 (sd
, addr
);
3908 OP_19D_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3910 uint16_t a
= (GPR (OP
[0]));
3911 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3912 trace_input ("storw", OP_REG
, OP_RP_BASE_DISPE20
, OP_VOID
);
3914 trace_output_32 (sd
, addr
);
3919 OP_13E_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3921 uint16_t a
= (GPR (OP
[0]));
3922 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3923 trace_input ("storw", OP_REG
, OP_RP_INDEX_DISPS20
, OP_VOID
);
3925 trace_output_32 (sd
, addr
);
3928 /* STORE-w IMM instruction *****/
3931 OP_C1_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3934 uint32_t addr
= OP
[1];
3935 trace_input ("storw", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
3937 trace_output_32 (sd
, addr
);
3942 OP_133_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3945 uint32_t addr
= OP
[1];
3946 trace_input ("storw", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
3948 trace_output_32 (sd
, addr
);
3953 OP_62_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
3957 trace_input ("storw", OP_CONSTANT4
, OP_R_INDEX8_ABS20
, OP_VOID
);
3960 addr
= (GPR32 (12)) + OP
[2];
3962 addr
= (GPR32 (13)) + OP
[2];
3965 trace_output_32 (sd
, addr
);
3970 OP_318_A (SIM_DESC sd
, SIM_CPU
*cpu
)
3973 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3974 trace_input ("storw", OP_CONSTANT4
, OP_RP_BASE_DISP14
, OP_VOID
);
3976 trace_output_32 (sd
, addr
);
3981 OP_C2_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
3984 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3985 trace_input ("storw", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
3987 trace_output_32 (sd
, addr
);
3992 OP_130_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
3995 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
3996 trace_input ("storw", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
3998 trace_output_32 (sd
, addr
);
4003 OP_C3_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4006 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
4007 trace_input ("storw", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
4009 trace_output_32 (sd
, addr
);
4015 OP_131_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
4018 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
4019 trace_input ("storw", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
4021 trace_output_32 (sd
, addr
);
4026 OP_132_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
4029 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
4030 trace_input ("storw", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
4032 trace_output_32 (sd
, addr
);
4038 OP_C7_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4040 uint32_t a
= GPR32 (OP
[0]);
4041 uint32_t addr
= OP
[1];
4042 trace_input ("stord", OP_REGP
, OP_ABS20_OUTPUT
, OP_VOID
);
4044 trace_output_32 (sd
, addr
);
4049 OP_13B_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
4051 uint32_t a
= GPR32 (OP
[0]);
4052 uint32_t addr
= OP
[1];
4053 trace_input ("stord", OP_REGP
, OP_ABS24_OUTPUT
, OP_VOID
);
4055 trace_output_32 (sd
, addr
);
4060 OP_66_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
4062 uint32_t addr
, a
= GPR32 (OP
[0]);
4063 trace_input ("stord", OP_REGP
, OP_R_INDEX8_ABS20
, OP_VOID
);
4066 addr
= (GPR32 (12)) + OP
[2];
4068 addr
= (GPR32 (13)) + OP
[2];
4071 trace_output_32 (sd
, addr
);
4076 OP_E_4 (SIM_DESC sd
, SIM_CPU
*cpu
)
4078 uint32_t a
= GPR32 (OP
[0]);
4079 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
4080 trace_input ("stord", OP_REGP
, OP_RP_BASE_DISPE4
, OP_VOID
);
4082 trace_output_32 (sd
, addr
);
4087 OP_EE_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4089 uint32_t a
= GPR32 (OP
[0]);
4090 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
4091 trace_input ("stord", OP_REGP
, OP_RP_INDEX_DISP0
, OP_VOID
);
4093 trace_output_32 (sd
, addr
);
4098 OP_31A_A (SIM_DESC sd
, SIM_CPU
*cpu
)
4100 uint32_t a
= GPR32 (OP
[0]);
4101 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
4102 trace_input ("stord", OP_REGP
, OP_RP_INDEX_DISP14
, OP_VOID
);
4104 trace_output_32 (sd
, addr
);
4109 OP_198_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
4111 uint32_t a
= GPR32 (OP
[0]);
4112 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
4113 trace_input ("stord", OP_REGP
, OP_R_BASE_DISPE20
, OP_VOID
);
4115 trace_output_32 (sd
, addr
);
4120 OP_138_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
4122 uint32_t a
= GPR32 (OP
[0]);
4123 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
4124 trace_input ("stord", OP_REGP
, OP_R_BASE_DISPS20
, OP_VOID
);
4126 trace_output_32 (sd
, addr
);
4131 OP_EF_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4133 uint32_t a
= GPR32 (OP
[0]);
4134 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
4135 trace_input ("stord", OP_REGP
, OP_RP_BASE_DISP16
, OP_VOID
);
4137 trace_output_32 (sd
, addr
);
4142 OP_139_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
4144 uint32_t a
= GPR32 (OP
[0]);
4145 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
4146 trace_input ("stord", OP_REGP
, OP_RP_BASE_DISPS20
, OP_VOID
);
4148 trace_output_32 (sd
, addr
);
4153 OP_199_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
4155 uint32_t a
= GPR32 (OP
[0]);
4156 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
4157 trace_input ("stord", OP_REGP
, OP_RP_BASE_DISPE20
, OP_VOID
);
4159 trace_output_32 (sd
, addr
);
4164 OP_13A_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
4166 uint32_t a
= GPR32 (OP
[0]);
4167 uint32_t addr
= (GPR32 (OP
[2])) + OP
[1];
4168 trace_input ("stord", OP_REGP
, OP_RP_INDEX_DISPS20
, OP_VOID
);
4170 trace_output_32 (sd
, addr
);
4175 OP_14D_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
4179 trace_input ("macuw", OP_REG
, OP_REG
, OP_REGP
);
4183 /*REVISIT FOR SATURATION and Q FORMAT. */
4184 SET_GPR32 (OP
[2], tmp
);
4185 trace_output_32 (sd
, tmp
);
4190 OP_14E_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
4193 uint16_t src1
, src2
;
4194 trace_input ("macuw", OP_REG
, OP_REG
, OP_REGP
);
4198 /*REVISIT FOR SATURATION. */
4199 SET_GPR32 (OP
[2], tmp
);
4200 trace_output_32 (sd
, tmp
);
4205 OP_14F_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
4209 trace_input ("macsw", OP_REG
, OP_REG
, OP_REGP
);
4213 /*REVISIT FOR SATURATION. */
4214 SET_GPR32 (OP
[2], tmp
);
4215 trace_output_32 (sd
, tmp
);
4221 OP_64_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4224 int8_t a
= (OP
[0]) & 0xff;
4225 int8_t b
= (GPR (OP
[1])) & 0xff;
4226 trace_input ("mulb", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
4227 tmp
= (a
* b
) & 0xff;
4228 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
4229 trace_output_16 (sd
, tmp
);
4234 OP_64B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
4237 int8_t a
= (OP
[0]) & 0xff, b
= (GPR (OP
[1])) & 0xff;
4238 trace_input ("mulb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4239 tmp
= (a
* b
) & 0xff;
4240 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
4241 trace_output_16 (sd
, tmp
);
4247 OP_65_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4250 int8_t a
= (GPR (OP
[0])) & 0xff, b
= (GPR (OP
[1])) & 0xff;
4251 trace_input ("mulb", OP_REG
, OP_REG
, OP_VOID
);
4252 tmp
= (a
* b
) & 0xff;
4253 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
4254 trace_output_16 (sd
, tmp
);
4260 OP_66_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4264 int16_t b
= (GPR (OP
[1]));
4265 trace_input ("mulw", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
4266 tmp
= (a
* b
) & 0xffff;
4267 SET_GPR (OP
[1], tmp
);
4268 trace_output_32 (sd
, tmp
);
4273 OP_66B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
4276 int16_t a
= OP
[0], b
= (GPR (OP
[1]));
4277 trace_input ("mulw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4278 tmp
= (a
* b
) & 0xffff;
4279 SET_GPR (OP
[1], tmp
);
4280 trace_output_32 (sd
, tmp
);
4286 OP_67_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4289 int16_t a
= (GPR (OP
[0])), b
= (GPR (OP
[1]));
4290 trace_input ("mulw", OP_REG
, OP_REG
, OP_VOID
);
4291 tmp
= (a
* b
) & 0xffff;
4292 SET_GPR (OP
[1], tmp
);
4293 trace_output_32 (sd
, tmp
);
4299 OP_B_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4302 int8_t a
= (GPR (OP
[0])) & 0xff, b
= (GPR (OP
[1])) & 0xff;
4303 trace_input ("mulsb", OP_REG
, OP_REG
, OP_VOID
);
4305 SET_GPR (OP
[1], tmp
);
4306 trace_output_32 (sd
, tmp
);
4311 OP_62_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4314 int16_t a
= (GPR (OP
[0])), b
= (GPR (OP
[1]));
4315 trace_input ("mulsw", OP_REG
, OP_REGP
, OP_VOID
);
4317 SET_GPR32 (OP
[1], tmp
);
4318 trace_output_32 (sd
, tmp
);
4323 OP_63_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4326 uint16_t a
= (GPR (OP
[0])), b
= (GPR (OP
[1]));
4327 trace_input ("muluw", OP_REG
, OP_REGP
, OP_VOID
);
4329 SET_GPR32 (OP
[1], tmp
);
4330 trace_output_32 (sd
, tmp
);
4336 OP_2C00_10 (SIM_DESC sd
, SIM_CPU
*cpu
)
4338 trace_input ("nop", OP_VOID
, OP_VOID
, OP_VOID
);
4341 ins_type_counters
[ (int)State
.ins_type
]--; /* don't count nops as normal instructions */
4342 switch (State
.ins_type
)
4345 ins_type_counters
[ (int)INS_UNKNOWN
]++;
4349 EXCEPTION (SIM_SIGTRAP
);
4351 trace_output_void (sd
);
4357 OP_24_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4359 uint8_t tmp
, a
= (OP
[0]) & 0xff, b
= (GPR (OP
[1])) & 0xff;
4360 trace_input ("orb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4362 SET_GPR (OP
[1], ((GPR (OP
[1]) | tmp
)));
4363 trace_output_16 (sd
, tmp
);
4368 OP_24B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
4370 uint8_t tmp
, a
= (OP
[0]) & 0xff, b
= (GPR (OP
[1])) & 0xff;
4371 trace_input ("orb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
4373 SET_GPR (OP
[1], ((GPR (OP
[1]) | tmp
)));
4374 trace_output_16 (sd
, tmp
);
4379 OP_25_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4381 uint8_t tmp
, a
= (GPR (OP
[0])) & 0xff, b
= (GPR (OP
[1])) & 0xff;
4382 trace_input ("orb", OP_REG
, OP_REG
, OP_VOID
);
4384 SET_GPR (OP
[1], ((GPR (OP
[1]) | tmp
)));
4385 trace_output_16 (sd
, tmp
);
4390 OP_26_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4392 uint16_t tmp
, a
= (OP
[0]), b
= (GPR (OP
[1]));
4393 trace_input ("orw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4395 SET_GPR (OP
[1], tmp
);
4396 trace_output_16 (sd
, tmp
);
4402 OP_26B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
4404 uint16_t tmp
, a
= (OP
[0]), b
= (GPR (OP
[1]));
4405 trace_input ("orw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
4407 SET_GPR (OP
[1], tmp
);
4408 trace_output_16 (sd
, tmp
);
4413 OP_27_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4415 uint16_t tmp
, a
= (GPR (OP
[0])), b
= (GPR (OP
[1]));
4416 trace_input ("orw", OP_REG
, OP_REG
, OP_VOID
);
4418 SET_GPR (OP
[1], tmp
);
4419 trace_output_16 (sd
, tmp
);
4425 OP_13_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
4428 uint16_t tmp
, b
= (GPR (OP
[1])) & 0xFF;
4429 trace_input ("lshb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4430 /* A positive count specifies a shift to the left;
4431 * A negative count specifies a shift to the right. */
4437 sign_flag
= 0; /* Reset sign_flag. */
4439 SET_GPR (OP
[1], ((tmp
& 0xFF) | ((GPR (OP
[1])) & 0xFF00)));
4440 trace_output_16 (sd
, tmp
);
4445 OP_44_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4447 uint16_t a
= (GPR (OP
[0])) & 0xff;
4448 uint16_t tmp
, b
= (GPR (OP
[1])) & 0xFF;
4449 trace_input ("lshb", OP_REG
, OP_REG
, OP_VOID
);
4450 if (a
& ((long)1 << 3))
4455 a
= (unsigned int) (a
& 0x7);
4457 /* A positive count specifies a shift to the left;
4458 * A negative count specifies a shift to the right. */
4464 sign_flag
= 0; /* Reset sign_flag. */
4465 SET_GPR (OP
[1], ((tmp
& 0xFF) | ((GPR (OP
[1])) & 0xFF00)));
4466 trace_output_16 (sd
, tmp
);
4471 OP_46_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4473 uint16_t tmp
, b
= GPR (OP
[1]);
4474 int16_t a
= GPR (OP
[0]);
4475 trace_input ("lshw", OP_REG
, OP_REG
, OP_VOID
);
4476 if (a
& ((long)1 << 4))
4481 a
= (unsigned int) (a
& 0xf);
4483 /* A positive count specifies a shift to the left;
4484 * A negative count specifies a shift to the right. */
4490 sign_flag
= 0; /* Reset sign_flag. */
4491 SET_GPR (OP
[1], (tmp
& 0xffff));
4492 trace_output_16 (sd
, tmp
);
4497 OP_49_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4499 uint16_t tmp
, b
= GPR (OP
[1]);
4501 trace_input ("lshw", OP_CONSTANT5
, OP_REG
, OP_VOID
);
4502 /* A positive count specifies a shift to the left;
4503 * A negative count specifies a shift to the right. */
4509 sign_flag
= 0; /* Reset sign_flag. */
4510 SET_GPR (OP
[1], (tmp
& 0xffff));
4511 trace_output_16 (sd
, tmp
);
4516 OP_25_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
4518 uint32_t tmp
, b
= GPR32 (OP
[1]);
4520 trace_input ("lshd", OP_CONSTANT6
, OP_REGP
, OP_VOID
);
4521 /* A positive count specifies a shift to the left;
4522 * A negative count specifies a shift to the right. */
4528 sign_flag
= 0; /* Reset sign flag. */
4530 SET_GPR32 (OP
[1], tmp
);
4531 trace_output_32 (sd
, tmp
);
4536 OP_47_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4538 uint32_t tmp
, b
= GPR32 (OP
[1]);
4539 uint16_t a
= GPR (OP
[0]);
4540 trace_input ("lshd", OP_REG
, OP_REGP
, OP_VOID
);
4541 if (a
& ((long)1 << 5))
4546 a
= (unsigned int) (a
& 0x1f);
4547 /* A positive count specifies a shift to the left;
4548 * A negative count specifies a shift to the right. */
4554 sign_flag
= 0; /* Reset sign flag. */
4556 SET_GPR32 (OP
[1], tmp
);
4557 trace_output_32 (sd
, tmp
);
4562 OP_80_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
4565 int8_t tmp
, b
= (GPR (OP
[1])) & 0xFF;
4566 trace_input ("ashub", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4567 /* A positive count specifies a shift to the left;
4568 * A negative count specifies a shift to the right. */
4574 sign_flag
= 0; /* Reset sign flag. */
4576 SET_GPR (OP
[1], ((tmp
& 0xFF) | ((GPR (OP
[1])) & 0xff00)));
4577 trace_output_16 (sd
, tmp
);
4582 OP_81_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
4585 int8_t tmp
, b
= (GPR (OP
[1])) & 0xFF;
4586 trace_input ("ashub", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4587 /* A positive count specifies a shift to the left;
4588 * A negative count specifies a shift to the right. */
4594 sign_flag
= 0; /* Reset sign flag. */
4596 SET_GPR (OP
[1], ((tmp
& 0xFF) | ((GPR (OP
[1])) & 0xFF00)));
4597 trace_output_16 (sd
, tmp
);
4603 OP_41_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4605 int16_t a
= (GPR (OP
[0]));
4606 int8_t tmp
, b
= (GPR (OP
[1])) & 0xFF;
4607 trace_input ("ashub", OP_REG
, OP_REG
, OP_VOID
);
4609 if (a
& ((long)1 << 3))
4614 a
= (unsigned int) (a
& 0x7);
4616 /* A positive count specifies a shift to the left;
4617 * A negative count specifies a shift to the right. */
4623 sign_flag
= 0; /* Reset sign flag. */
4625 SET_GPR (OP
[1], ((tmp
& 0xFF) | ((GPR (OP
[1])) & 0xFF00)));
4626 trace_output_16 (sd
, tmp
);
4632 OP_42_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4634 int16_t tmp
, b
= GPR (OP
[1]);
4636 trace_input ("ashuw", OP_CONSTANT5
, OP_REG
, OP_VOID
);
4637 /* A positive count specifies a shift to the left;
4638 * A negative count specifies a shift to the right. */
4644 sign_flag
= 0; /* Reset sign flag. */
4646 SET_GPR (OP
[1], (tmp
& 0xffff));
4647 trace_output_16 (sd
, tmp
);
4652 OP_43_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4654 int16_t tmp
, b
= GPR (OP
[1]);
4656 trace_input ("ashuw", OP_CONSTANT5
, OP_REG
, OP_VOID
);
4657 /* A positive count specifies a shift to the left;
4658 * A negative count specifies a shift to the right. */
4664 sign_flag
= 0; /* Reset sign flag. */
4665 SET_GPR (OP
[1], (tmp
& 0xffff));
4666 trace_output_16 (sd
, tmp
);
4671 OP_45_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4674 int16_t a
= GPR (OP
[0]), b
= GPR (OP
[1]);
4675 trace_input ("ashuw", OP_REG
, OP_REG
, OP_VOID
);
4677 if (a
& ((long)1 << 4))
4682 a
= (unsigned int) (a
& 0xf);
4683 /* A positive count specifies a shift to the left;
4684 * A negative count specifies a shift to the right. */
4691 sign_flag
= 0; /* Reset sign flag. */
4692 SET_GPR (OP
[1], (tmp
& 0xffff));
4693 trace_output_16 (sd
, tmp
);
4698 OP_26_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
4700 int32_t tmp
,b
= GPR32 (OP
[1]);
4702 trace_input ("ashud", OP_CONSTANT6
, OP_REGP
, OP_VOID
);
4703 /* A positive count specifies a shift to the left;
4704 * A negative count specifies a shift to the right. */
4710 sign_flag
= 0; /* Reset sign flag. */
4711 SET_GPR32 (OP
[1], tmp
);
4712 trace_output_32 (sd
, tmp
);
4717 OP_27_7 (SIM_DESC sd
, SIM_CPU
*cpu
)
4720 int32_t a
= OP
[0], b
= GPR32 (OP
[1]);
4721 trace_input ("ashud", OP_CONSTANT6
, OP_REGP
, OP_VOID
);
4722 /* A positive count specifies a shift to the left;
4723 * A negative count specifies a shift to the right. */
4729 sign_flag
= 0; /* Reset sign flag. */
4730 SET_GPR32 (OP
[1], tmp
);
4731 trace_output_32 (sd
, tmp
);
4736 OP_48_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4739 int32_t a
= GPR32 (OP
[0]), b
= GPR32 (OP
[1]);
4740 trace_input ("ashud", OP_REGP
, OP_REGP
, OP_VOID
);
4742 if (a
& ((long)1 << 5))
4747 a
= (unsigned int) (a
& 0x1f);
4748 /* A positive count specifies a shift to the left;
4749 * A negative count specifies a shift to the right. */
4755 sign_flag
= 0; /* Reset sign flag. */
4756 SET_GPR32 (OP
[1], tmp
);
4757 trace_output_32 (sd
, tmp
);
4763 OP_16_D (SIM_DESC sd
, SIM_CPU
*cpu
)
4765 uint32_t addr
= GPR (1);
4766 uint16_t count
= OP
[0], reg
= 2;
4767 trace_input ("storm", OP_CONSTANT4
, OP_VOID
, OP_VOID
);
4770 trace_output_void (sd
);
4771 EXCEPTION (SIM_SIGBUS
);
4776 SW (addr
, (GPR (reg
)));
4780 if (reg
== 6) reg
= 8;
4785 trace_output_void (sd
);
4791 OP_17_D (SIM_DESC sd
, SIM_CPU
*cpu
)
4793 uint32_t addr
= GPR32 (6);
4794 uint16_t count
= OP
[0], reg
= 2;
4795 trace_input ("stormp", OP_CONSTANT4
, OP_VOID
, OP_VOID
);
4798 trace_output_void (sd
);
4799 EXCEPTION (SIM_SIGBUS
);
4804 SW (addr
, (GPR (reg
)));
4808 if (reg
== 6) reg
= 8;
4811 SET_GPR32 (6, addr
);
4812 trace_output_void (sd
);
4817 OP_38_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4820 uint8_t b
= (GPR (OP
[1])) & 0xff;
4821 uint16_t tmp
= (~a
+ 1 + b
) & 0xff;
4822 trace_input ("subb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4823 /* see ../common/sim-alu.h for a more extensive discussion on how to
4824 compute the carry/overflow bits. */
4825 SET_PSR_C (tmp
> 0xff);
4826 SET_PSR_F (((a
& 0x80) != (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
4827 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
4828 trace_output_16 (sd
, tmp
);
4833 OP_38B_C (SIM_DESC sd
, SIM_CPU
*cpu
)
4835 uint8_t a
= OP
[0] & 0xFF;
4836 uint8_t b
= (GPR (OP
[1])) & 0xFF;
4837 uint16_t tmp
= (~a
+ 1 + b
) & 0xFF;
4838 trace_input ("subb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
4839 /* see ../common/sim-alu.h for a more extensive discussion on how to
4840 compute the carry/overflow bits. */
4841 SET_PSR_C (tmp
> 0xff);
4842 SET_PSR_F (((a
& 0x80) != (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
4843 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
4844 trace_output_16 (sd
, tmp
);
4849 OP_39_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4851 uint8_t a
= (GPR (OP
[0])) & 0xFF;
4852 uint8_t b
= (GPR (OP
[1])) & 0xFF;
4853 uint16_t tmp
= (~a
+ 1 + b
) & 0xff;
4854 trace_input ("subb", OP_REG
, OP_REG
, OP_VOID
);
4855 /* see ../common/sim-alu.h for a more extensive discussion on how to
4856 compute the carry/overflow bits. */
4857 SET_PSR_C (tmp
> 0xff);
4858 SET_PSR_F (((a
& 0x80) != (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
4859 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
4860 trace_output_16 (sd
, tmp
);
4865 OP_3A_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4868 uint16_t b
= GPR (OP
[1]);
4869 uint16_t tmp
= (~a
+ 1 + b
);
4870 trace_input ("subw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4871 /* see ../common/sim-alu.h for a more extensive discussion on how to
4872 compute the carry/overflow bits. */
4873 SET_PSR_C (tmp
> 0xffff);
4874 SET_PSR_F (((a
& 0x8000) != (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
4875 SET_GPR (OP
[1], tmp
);
4876 trace_output_16 (sd
, tmp
);
4881 OP_3AB_C (SIM_DESC sd
, SIM_CPU
*cpu
)
4884 uint16_t b
= GPR (OP
[1]);
4885 uint32_t tmp
= (~a
+ 1 + b
);
4886 trace_input ("subw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
4887 /* see ../common/sim-alu.h for a more extensive discussion on how to
4888 compute the carry/overflow bits. */
4889 SET_PSR_C (tmp
> 0xffff);
4890 SET_PSR_F (((a
& 0x8000) != (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
4891 SET_GPR (OP
[1], tmp
& 0xffff);
4892 trace_output_16 (sd
, tmp
);
4897 OP_3B_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4899 uint16_t a
= GPR (OP
[0]);
4900 uint16_t b
= GPR (OP
[1]);
4901 uint32_t tmp
= (~a
+ 1 + b
);
4902 trace_input ("subw", OP_REG
, OP_REG
, OP_VOID
);
4903 /* see ../common/sim-alu.h for a more extensive discussion on how to
4904 compute the carry/overflow bits. */
4905 SET_PSR_C (tmp
> 0xffff);
4906 SET_PSR_F (((a
& 0x8000) != (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
4907 SET_GPR (OP
[1], tmp
& 0xffff);
4908 trace_output_16 (sd
, tmp
);
4913 OP_3C_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4916 uint8_t b
= (GPR (OP
[1])) & 0xff;
4917 //uint16_t tmp1 = a + 1;
4918 uint16_t tmp1
= a
+ (PSR_C
);
4919 uint16_t tmp
= (~tmp1
+ 1 + b
);
4920 trace_input ("subcb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4921 /* see ../common/sim-alu.h for a more extensive discussion on how to
4922 compute the carry/overflow bits. */
4923 SET_PSR_C (tmp
> 0xff);
4924 SET_PSR_F (((a
& 0x80) != (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
4925 SET_GPR (OP
[1], tmp
);
4926 trace_output_16 (sd
, tmp
);
4931 OP_3CB_C (SIM_DESC sd
, SIM_CPU
*cpu
)
4934 uint16_t b
= (GPR (OP
[1])) & 0xff;
4935 //uint16_t tmp1 = a + 1;
4936 uint16_t tmp1
= a
+ (PSR_C
);
4937 uint16_t tmp
= (~tmp1
+ 1 + b
);
4938 trace_input ("subcb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
4939 /* see ../common/sim-alu.h for a more extensive discussion on how to
4940 compute the carry/overflow bits. */
4941 SET_PSR_C (tmp
> 0xff);
4942 SET_PSR_F (((a
& 0x80) != (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
4943 SET_GPR (OP
[1], tmp
);
4944 trace_output_16 (sd
, tmp
);
4949 OP_3D_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4951 uint16_t a
= (GPR (OP
[0])) & 0xff;
4952 uint16_t b
= (GPR (OP
[1])) & 0xff;
4953 uint16_t tmp1
= a
+ (PSR_C
);
4954 uint16_t tmp
= (~tmp1
+ 1 + b
);
4955 trace_input ("subcb", OP_REG
, OP_REG
, OP_VOID
);
4956 /* see ../common/sim-alu.h for a more extensive discussion on how to
4957 compute the carry/overflow bits. */
4958 SET_PSR_C (tmp
> 0xff);
4959 SET_PSR_F (((a
& 0x80) != (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
4960 SET_GPR (OP
[1], tmp
);
4961 trace_output_16 (sd
, tmp
);
4966 OP_3E_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
4968 uint16_t a
= OP
[0], b
= (GPR (OP
[1]));
4969 uint16_t tmp1
= a
+ (PSR_C
);
4970 uint16_t tmp
= (~tmp1
+ 1 + b
);
4971 trace_input ("subcw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4972 /* see ../common/sim-alu.h for a more extensive discussion on how to
4973 compute the carry/overflow bits. */
4974 SET_PSR_C (tmp
> 0xffff);
4975 SET_PSR_F (((a
& 0x8000) != (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
4976 SET_GPR (OP
[1], tmp
);
4977 trace_output_16 (sd
, tmp
);
4982 OP_3EB_C (SIM_DESC sd
, SIM_CPU
*cpu
)
4985 uint16_t b
= GPR (OP
[1]);
4986 uint16_t tmp1
= a
+ (PSR_C
);
4987 uint16_t tmp
= (~tmp1
+ 1 + b
);
4988 trace_input ("subcw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
4989 /* see ../common/sim-alu.h for a more extensive discussion on how to
4990 compute the carry/overflow bits. */
4991 SET_PSR_C (tmp
> 0xffff);
4992 SET_PSR_F (((a
& 0x8000) != (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
4993 SET_GPR (OP
[1], tmp
);
4994 trace_output_16 (sd
, tmp
);
4999 OP_3F_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
5001 uint16_t a
= (GPR (OP
[0])), b
= (GPR (OP
[1]));
5002 uint16_t tmp1
= a
+ (PSR_C
);
5003 uint16_t tmp
= (~tmp1
+ 1 + b
);
5004 trace_input ("subcw", OP_REG
, OP_REG
, OP_VOID
);
5005 /* see ../common/sim-alu.h for a more extensive discussion on how to
5006 compute the carry/overflow bits. */
5007 SET_PSR_C (tmp
> 0xffff);
5008 SET_PSR_F (((a
& 0x8000) != (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
5009 SET_GPR (OP
[1], tmp
);
5010 trace_output_16 (sd
, tmp
);
5015 OP_3_C (SIM_DESC sd
, SIM_CPU
*cpu
)
5018 uint32_t b
= GPR32 (OP
[1]);
5019 uint32_t tmp
= (~a
+ 1 + b
);
5020 trace_input ("subd", OP_CONSTANT32
, OP_REGP
, OP_VOID
);
5021 /* see ../common/sim-alu.h for a more extensive discussion on how to
5022 compute the carry/overflow bits. */
5023 SET_PSR_C (tmp
> 0xffffffff);
5024 SET_PSR_F (((a
& 0x80000000) != (b
& 0x80000000)) &&
5025 ((b
& 0x80000000) != (tmp
& 0x80000000)));
5026 SET_GPR32 (OP
[1], tmp
);
5027 trace_output_32 (sd
, tmp
);
5032 OP_14C_14 (SIM_DESC sd
, SIM_CPU
*cpu
)
5034 uint32_t a
= GPR32 (OP
[0]);
5035 uint32_t b
= GPR32 (OP
[1]);
5036 uint32_t tmp
= (~a
+ 1 + b
);
5037 trace_input ("subd", OP_REGP
, OP_REGP
, OP_VOID
);
5038 /* see ../common/sim-alu.h for a more extensive discussion on how to
5039 compute the carry/overflow bits. */
5040 SET_PSR_C (tmp
> 0xffffffff);
5041 SET_PSR_F (((a
& 0x80000000) != (b
& 0x80000000)) &&
5042 ((b
& 0x80000000) != (tmp
& 0x80000000)));
5043 SET_GPR32 (OP
[1], tmp
);
5044 trace_output_32 (sd
, tmp
);
5049 OP_C_C (SIM_DESC sd
, SIM_CPU
*cpu
)
5051 host_callback
*cb
= STATE_CALLBACK (sd
);
5054 trace_input ("excp", OP_CONSTANT4
, OP_VOID
, OP_VOID
);
5058 #if (DEBUG & DEBUG_TRAP) == 0
5061 uint16_t vec
= OP
[0] + TRAP_VECTOR_START
;
5064 SET_PSR (PSR
& PSR_SM_BIT
);
5069 #else /* if debugging use trap to print registers */
5072 static int first_time
= 1;
5077 sim_io_printf (sd
, "Trap # PC ");
5078 for (i
= 0; i
< 16; i
++)
5079 sim_io_printf (sd
, " %sr%d", (i
> 9) ? "" : " ", i
);
5080 sim_io_printf (sd
, " a0 a1 f0 f1 c\n");
5083 sim_io_printf (sd
, "Trap %2d 0x%.4x:", (int)OP
[0], (int)PC
);
5085 for (i
= 0; i
< 16; i
++)
5086 sim_io_printf (sd
, " %.4x", (int) GPR (i
));
5088 for (i
= 0; i
< 2; i
++)
5089 sim_io_printf (sd
, " %.2x%.8lx",
5090 ((int)(ACC (i
) >> 32) & 0xff),
5091 ((unsigned long) ACC (i
)) & 0xffffffff);
5093 sim_io_printf (sd
, " %d %d %d\n",
5094 PSR_F
!= 0, PSR_F
!= 0, PSR_C
!= 0);
5095 sim_io_flush_stdout (sd
);
5099 case 8: /* new system call trap */
5100 /* Trap 8 is used for simulating low-level I/O */
5102 uint32_t result
= 0;
5105 /* Registers passed to trap 0. */
5107 #define FUNC GPR (0) /* function number. */
5108 #define PARM1 GPR (2) /* optional parm 1. */
5109 #define PARM2 GPR (3) /* optional parm 2. */
5110 #define PARM3 GPR (4) /* optional parm 3. */
5111 #define PARM4 GPR (5) /* optional parm 4. */
5113 /* Registers set by trap 0 */
5115 #define RETVAL(X) do { result = (0xffff & (X));SET_GPR (0, result);} while (0)
5116 #define RETVAL32(X) do { result = (X); SET_GPR32 (0, result);} while (0)
5117 #define RETERR(X) SET_GPR (4, (X)) /* return error code. */
5119 /* Turn a pointer in a register into a pointer into real memory. */
5121 #define MEMPTR(x) sim_core_trans_addr (sd, cpu, read_map, x)
5125 #if !defined(__GO32__) && !defined(_WIN32)
5126 case TARGET_NEWLIB_CR16_SYS_fork
:
5127 trace_input ("<fork>", OP_VOID
, OP_VOID
, OP_VOID
);
5129 trace_output_16 (sd
, result
);
5133 case TARGET_NEWLIB_CR16_SYS_getpid
:
5134 trace_input ("<getpid>", OP_VOID
, OP_VOID
, OP_VOID
);
5136 trace_output_16 (sd
, result
);
5139 case TARGET_NEWLIB_CR16_SYS_kill
:
5140 trace_input ("<kill>", OP_REG
, OP_REG
, OP_VOID
);
5141 if (PARM1
== getpid ())
5143 trace_output_void (sd
);
5152 case 1: os_sig
= SIGHUP
; break;
5155 case 2: os_sig
= SIGINT
; break;
5158 case 3: os_sig
= SIGQUIT
; break;
5161 case 4: os_sig
= SIGILL
; break;
5164 case 5: os_sig
= SIGTRAP
; break;
5167 case 6: os_sig
= SIGABRT
; break;
5168 #elif defined(SIGIOT)
5169 case 6: os_sig
= SIGIOT
; break;
5172 case 7: os_sig
= SIGEMT
; break;
5175 case 8: os_sig
= SIGFPE
; break;
5178 case 9: os_sig
= SIGKILL
; break;
5181 case 10: os_sig
= SIGBUS
; break;
5184 case 11: os_sig
= SIGSEGV
; break;
5187 case 12: os_sig
= SIGSYS
; break;
5190 case 13: os_sig
= SIGPIPE
; break;
5193 case 14: os_sig
= SIGALRM
; break;
5196 case 15: os_sig
= SIGTERM
; break;
5199 case 16: os_sig
= SIGURG
; break;
5202 case 17: os_sig
= SIGSTOP
; break;
5205 case 18: os_sig
= SIGTSTP
; break;
5208 case 19: os_sig
= SIGCONT
; break;
5211 case 20: os_sig
= SIGCHLD
; break;
5212 #elif defined(SIGCLD)
5213 case 20: os_sig
= SIGCLD
; break;
5216 case 21: os_sig
= SIGTTIN
; break;
5219 case 22: os_sig
= SIGTTOU
; break;
5222 case 23: os_sig
= SIGIO
; break;
5223 #elif defined (SIGPOLL)
5224 case 23: os_sig
= SIGPOLL
; break;
5227 case 24: os_sig
= SIGXCPU
; break;
5230 case 25: os_sig
= SIGXFSZ
; break;
5233 case 26: os_sig
= SIGVTALRM
; break;
5236 case 27: os_sig
= SIGPROF
; break;
5239 case 28: os_sig
= SIGWINCH
; break;
5242 case 29: os_sig
= SIGLOST
; break;
5245 case 30: os_sig
= SIGUSR1
; break;
5248 case 31: os_sig
= SIGUSR2
; break;
5254 trace_output_void (sd
);
5255 sim_io_printf (sd
, "Unknown signal %d\n", PARM2
);
5256 sim_io_flush_stdout (sd
);
5257 EXCEPTION (SIM_SIGILL
);
5261 RETVAL (kill (PARM1
, PARM2
));
5262 trace_output_16 (sd
, result
);
5267 case TARGET_NEWLIB_CR16_SYS_execve
:
5268 trace_input ("<execve>", OP_VOID
, OP_VOID
, OP_VOID
);
5269 RETVAL (execve (MEMPTR (PARM1
), (char **) MEMPTR (PARM2
<<16|PARM3
),
5270 (char **)MEMPTR (PARM4
)));
5271 trace_output_16 (sd
, result
);
5274 case TARGET_NEWLIB_CR16_SYS_execv
:
5275 trace_input ("<execv>", OP_VOID
, OP_VOID
, OP_VOID
);
5276 RETVAL (execve (MEMPTR (PARM1
), (char **) MEMPTR (PARM2
), NULL
));
5277 trace_output_16 (sd
, result
);
5280 case TARGET_NEWLIB_CR16_SYS_pipe
:
5285 trace_input ("<pipe>", OP_VOID
, OP_VOID
, OP_VOID
);
5287 RETVAL (pipe (host_fd
));
5288 SW (buf
, host_fd
[0]);
5289 buf
+= sizeof(uint16_t);
5290 SW (buf
, host_fd
[1]);
5291 trace_output_16 (sd
, result
);
5295 case TARGET_NEWLIB_CR16_SYS_wait
:
5298 trace_input ("<wait>", OP_REG
, OP_VOID
, OP_VOID
);
5299 RETVAL (wait (&status
));
5302 trace_output_16 (sd
, result
);
5306 case TARGET_NEWLIB_CR16_SYS_getpid
:
5307 trace_input ("<getpid>", OP_VOID
, OP_VOID
, OP_VOID
);
5309 trace_output_16 (sd
, result
);
5312 case TARGET_NEWLIB_CR16_SYS_kill
:
5313 trace_input ("<kill>", OP_REG
, OP_REG
, OP_VOID
);
5314 trace_output_void (sd
);
5319 case TARGET_NEWLIB_CR16_SYS_read
:
5320 trace_input ("<read>", OP_REG
, OP_MEMREF
, OP_REG
);
5321 RETVAL (cb
->read (cb
, PARM1
,
5322 MEMPTR (((unsigned long)PARM3
<< 16)
5323 | ((unsigned long)PARM2
)), PARM4
));
5324 trace_output_16 (sd
, result
);
5327 case TARGET_NEWLIB_CR16_SYS_write
:
5328 trace_input ("<write>", OP_REG
, OP_MEMREF
, OP_REG
);
5329 RETVAL ((int)cb
->write (cb
, PARM1
,
5330 MEMPTR (((unsigned long)PARM3
<< 16)
5332 trace_output_16 (sd
, result
);
5335 case TARGET_NEWLIB_CR16_SYS_lseek
:
5336 trace_input ("<lseek>", OP_REG
, OP_REGP
, OP_REG
);
5337 RETVAL32 (cb
->lseek (cb
, PARM1
, ((((long) PARM3
) << 16) | PARM2
),
5339 trace_output_32 (sd
, result
);
5342 case TARGET_NEWLIB_CR16_SYS_close
:
5343 trace_input ("<close>", OP_REG
, OP_VOID
, OP_VOID
);
5344 RETVAL (cb
->close (cb
, PARM1
));
5345 trace_output_16 (sd
, result
);
5348 case TARGET_NEWLIB_CR16_SYS_open
:
5349 trace_input ("<open>", OP_MEMREF
, OP_REG
, OP_VOID
);
5350 RETVAL32 (cb
->open (cb
, MEMPTR ((((unsigned long)PARM2
) << 16)
5352 trace_output_32 (sd
, result
);
5355 case TARGET_NEWLIB_CR16_SYS_rename
:
5356 trace_input ("<rename>", OP_MEMREF
, OP_MEMREF
, OP_VOID
);
5357 RETVAL (cb
->rename (cb
, MEMPTR ((((unsigned long)PARM2
) << 16) | PARM1
),
5358 MEMPTR ((((unsigned long)PARM4
) << 16) | PARM3
)));
5359 trace_output_16 (sd
, result
);
5362 case 0x408: /* REVISIT: Added a dummy getenv call. */
5363 trace_input ("<getenv>", OP_MEMREF
, OP_MEMREF
, OP_VOID
);
5365 trace_output_32 (sd
, result
);
5368 case TARGET_NEWLIB_CR16_SYS_exit
:
5369 trace_input ("<exit>", OP_VOID
, OP_VOID
, OP_VOID
);
5370 trace_output_void (sd
);
5371 sim_engine_halt (sd
, cpu
, NULL
, PC
, sim_exited
, GPR (2));
5374 case TARGET_NEWLIB_CR16_SYS_unlink
:
5375 trace_input ("<unlink>", OP_MEMREF
, OP_VOID
, OP_VOID
);
5376 RETVAL (cb
->unlink (cb
, MEMPTR (((unsigned long)PARM2
<< 16) | PARM1
)));
5377 trace_output_16 (sd
, result
);
5380 case TARGET_NEWLIB_CR16_SYS_stat
:
5381 trace_input ("<stat>", OP_VOID
, OP_VOID
, OP_VOID
);
5382 /* stat system call. */
5384 struct stat host_stat
;
5387 RETVAL (stat (MEMPTR ((((unsigned long)PARM2
) << 16)|PARM1
), &host_stat
));
5391 /* The hard-coded offsets and sizes were determined by using
5392 * the CR16 compiler on a test program that used struct stat.
5394 SW (buf
, host_stat
.st_dev
);
5395 SW (buf
+2, host_stat
.st_ino
);
5396 SW (buf
+4, host_stat
.st_mode
);
5397 SW (buf
+6, host_stat
.st_nlink
);
5398 SW (buf
+8, host_stat
.st_uid
);
5399 SW (buf
+10, host_stat
.st_gid
);
5400 SW (buf
+12, host_stat
.st_rdev
);
5401 SLW (buf
+16, host_stat
.st_size
);
5402 SLW (buf
+20, host_stat
.st_atime
);
5403 SLW (buf
+28, host_stat
.st_mtime
);
5404 SLW (buf
+36, host_stat
.st_ctime
);
5406 trace_output_16 (sd
, result
);
5409 case TARGET_NEWLIB_CR16_SYS_chown
:
5410 trace_input ("<chown>", OP_VOID
, OP_VOID
, OP_VOID
);
5411 RETVAL (chown (MEMPTR (PARM1
), PARM2
, PARM3
));
5412 trace_output_16 (sd
, result
);
5415 case TARGET_NEWLIB_CR16_SYS_chmod
:
5416 trace_input ("<chmod>", OP_VOID
, OP_VOID
, OP_VOID
);
5417 RETVAL (chmod (MEMPTR (PARM1
), PARM2
));
5418 trace_output_16 (sd
, result
);
5421 case TARGET_NEWLIB_CR16_SYS_utime
:
5422 trace_input ("<utime>", OP_REG
, OP_REG
, OP_REG
);
5423 /* Cast the second argument to void *, to avoid type mismatch
5424 if a prototype is present. */
5425 RETVAL (utime (MEMPTR (PARM1
), (void *) MEMPTR (PARM2
)));
5426 trace_output_16 (sd
, result
);
5429 case TARGET_NEWLIB_CR16_SYS_time
:
5430 trace_input ("<time>", OP_VOID
, OP_VOID
, OP_REG
);
5431 RETVAL32 (time (NULL
));
5432 trace_output_32 (sd
, result
);
5439 case TRAP_BREAKPOINT
:
5442 trace_output_void (sd
);
5443 EXCEPTION (SIM_SIGTRAP
);
5445 case SIGTRAP
: /* supervisor call ? */
5446 trace_output_void (sd
);
5447 sim_engine_halt (sd
, cpu
, NULL
, PC
, sim_exited
, GPR (2));
5450 cb
->error (cb
, "Unknown syscall %d", FUNC
);
5454 if ((uint16_t) result
== (uint16_t) -1)
5455 RETERR (cb
->get_errno (cb
));
5466 OP_3_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
5468 uint16_t a
= OP
[0] + 1, b
= OP
[1], i
= 0;
5469 uint32_t tmp
, sp_addr
= (GPR32 (15)) - (a
* 2) - 4, is_regp
= 0;
5470 trace_input ("push", OP_CONSTANT3
, OP_REG
, OP_REG
);
5476 SW (sp_addr
, (GPR (b
+i
)));
5482 tmp
= (GPR32 (b
+i
));
5484 tmp
= (GPR32 (b
+i
-1));
5503 /* Store RA address. */
5507 sp_addr
= (GPR32 (15)) - (a
* 2) - 4;
5508 SET_GPR32 (15, sp_addr
); /* Update SP address. */
5510 trace_output_void (sd
);
5515 OP_1_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
5517 uint32_t sp_addr
, tmp
, is_regp
= 0;
5518 uint16_t a
= OP
[0] + 1, b
= OP
[1], c
= OP
[2], i
= 0;
5519 trace_input ("push", OP_CONSTANT3
, OP_REG
, OP_VOID
);
5522 sp_addr
= (GPR32 (15)) - (a
* 2) - 4;
5524 sp_addr
= (GPR32 (15)) - (a
* 2);
5530 SW (sp_addr
, (GPR (b
+i
)));
5536 tmp
= (GPR32 (b
+i
));
5538 tmp
= (GPR32 (b
+i
-1));
5557 /* Store RA address. */
5560 sp_addr
= (GPR32 (15)) - (a
* 2) - 4;
5563 sp_addr
= (GPR32 (15)) - (a
* 2);
5565 SET_GPR32 (15, sp_addr
); /* Update SP address. */
5567 trace_output_void (sd
);
5573 OP_11E_10 (SIM_DESC sd
, SIM_CPU
*cpu
)
5575 uint32_t sp_addr
= (GPR32 (15)), tmp
;
5576 trace_input ("push", OP_VOID
, OP_VOID
, OP_VOID
);
5578 SLW(sp_addr
-4,tmp
); /* Store RA address. */
5579 SET_GPR32 (15, (sp_addr
- 4)); /* Update SP address. */
5580 trace_output_void (sd
);
5586 OP_5_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
5588 uint16_t a
= OP
[0] + 1, b
= OP
[1], i
= 0;
5589 uint32_t tmp
, sp_addr
= (GPR32 (15)), is_regp
= 0;;
5590 trace_input ("pop", OP_CONSTANT3
, OP_REG
, OP_REG
);
5596 SET_GPR ((b
+i
), RW(sp_addr
));
5612 tmp
= (tmp
<< 16) | (GPR32 (b
+i
));
5614 tmp
= (tmp
<< 16) | (GPR32 (b
+i
-1));
5618 SET_GPR32 ((b
+i
), (((tmp
& 0xffff) << 16)
5619 | ((tmp
>> 16) & 0xffff)));
5621 SET_GPR32 ((b
+i
-1), (((tmp
& 0xffff) << 16)
5622 | ((tmp
>> 16) & 0xffff)));
5629 tmp
= RLW(sp_addr
); /* store RA also. */
5630 SET_GPR32 (14, (((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff)));
5632 SET_GPR32 (15, (sp_addr
+ 4)); /* Update SP address. */
5634 trace_output_void (sd
);
5639 OP_2_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
5641 uint16_t a
= OP
[0] + 1, b
= OP
[1], c
= OP
[2], i
= 0;
5642 uint32_t tmp
, sp_addr
= (GPR32 (15)), is_regp
= 0;
5643 trace_input ("pop", OP_CONSTANT3
, OP_REG
, OP_VOID
);
5649 SET_GPR ((b
+i
), RW(sp_addr
));
5665 tmp
= ((tmp
<< 16) & 0xffffffff) | (GPR32 (b
+i
));
5667 tmp
= ((tmp
<< 16) & 0xffffffff) | (GPR32 (b
+i
-1));
5671 SET_GPR32 ((b
+i
), (((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff)));
5673 SET_GPR32 ((b
+i
-1), (((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff)));
5681 tmp
= RLW(sp_addr
); /* Store RA Reg. */
5682 SET_GPR32 (14, (((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff)));
5686 SET_GPR32 (15, sp_addr
); /* Update SP address. */
5688 trace_output_void (sd
);
5693 OP_21E_10 (SIM_DESC sd
, SIM_CPU
*cpu
)
5695 uint32_t sp_addr
= GPR32 (15);
5697 trace_input ("pop", OP_VOID
, OP_VOID
, OP_VOID
);
5700 SET_GPR32 (14, (((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff)));
5701 SET_GPR32 (15, (sp_addr
+4)); /* Update SP address. */
5703 trace_output_void (sd
);
5708 OP_7_9 (SIM_DESC sd
, SIM_CPU
*cpu
)
5710 trace_input ("popret", OP_CONSTANT3
, OP_REG
, OP_REG
);
5712 JMP(((GPR32(14)) << 1) & 0xffffff);
5714 trace_output_void (sd
);
5719 OP_3_8 (SIM_DESC sd
, SIM_CPU
*cpu
)
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);