1 /* Simulation code for the CR16 processor.
2 Copyright (C) 2008 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 along
18 with this program. If not, see <http://www.gnu.org/licenses/>. */
25 #include <sys/types.h>
36 #include "targ-vals.h"
38 extern char *strrchr ();
47 OP_UCONSTANT3_1_OUTPUT
,
51 OP_CONSTANT4_1_OUTPUT
,
59 OP_UCONSTANT16_OUTPUT
,
63 OP_UCONSTANT20_OUTPUT
,
65 OP_UCONSTANT32_OUTPUT
,
86 OP_R_BASE_DISPS16_OUTPUT
,
88 OP_R_BASE_DISP20_OUTPUT
,
90 OP_R_BASE_DISPS20_OUTPUT
,
92 OP_R_BASE_DISPE20_OUTPUT
,
95 OP_RP_BASE_DISPE0_OUTPUT
,
97 OP_RP_BASE_DISP4_OUTPUT
,
99 OP_RP_BASE_DISPE4_OUTPUT
,
101 OP_RP_BASE_DISP14_OUTPUT
,
103 OP_RP_BASE_DISP16_OUTPUT
,
105 OP_RP_BASE_DISP20_OUTPUT
,
107 OP_RP_BASE_DISPS20_OUTPUT
,
109 OP_RP_BASE_DISPE20_OUTPUT
,
112 OP_R_INDEX7_ABS20_OUTPUT
,
114 OP_R_INDEX8_ABS20_OUTPUT
,
117 OP_RP_INDEX_DISP0_OUTPUT
,
119 OP_RP_INDEX_DISP14_OUTPUT
,
121 OP_RP_INDEX_DISP20_OUTPUT
,
123 OP_RP_INDEX_DISPS20_OUTPUT
,
141 PSR_MASK
= (PSR_I_BIT
151 /* The following bits in the PSR _can't_ be set by instructions such
153 PSR_HW_MASK
= (PSR_MASK
)
156 /* cond Code Condition True State
157 * EQ Equal Z flag is 1
158 * NE Not Equal Z flag is 0
159 * CS Carry Set C flag is 1
160 * CC Carry Clear C flag is 0
161 * HI Higher L flag is 1
162 * LS Lower or Same L flag is 0
163 * GT Greater Than N flag is 1
164 * LE Less Than or Equal To N flag is 0
165 * FS Flag Set F flag is 1
166 * FC Flag Clear F flag is 0
167 * LO Lower Z and L flags are 0
168 * HS Higher or Same Z or L flag is 1
169 * LT Less Than Z and N flags are 0
170 * GE Greater Than or Equal To Z or N flag is 1. */
172 int cond_stat(int cc
)
176 case 0: return PSR_Z
; break;
177 case 1: return !PSR_Z
; break;
178 case 2: return PSR_C
; break;
179 case 3: return !PSR_C
; break;
180 case 4: return PSR_L
; break;
181 case 5: return !PSR_L
; break;
182 case 6: return PSR_N
; break;
183 case 7: return !PSR_N
; break;
184 case 8: return PSR_F
; break;
185 case 9: return !PSR_F
; break;
186 case 10: return !PSR_Z
&& !PSR_L
; break;
187 case 11: return PSR_Z
|| PSR_L
; break;
188 case 12: return !PSR_Z
&& !PSR_N
; break;
189 case 13: return PSR_Z
|| PSR_N
; break;
190 case 14: return 1; break; /*ALWAYS. */
192 // case NEVER: return false; break;
194 //panic("Shouldn't have NO_COND_CODE in an actual instruction!");
202 move_to_cr (int cr
, creg_t mask
, creg_t val
, int psw_hw_p
)
204 /* A MASK bit is set when the corresponding bit in the CR should
206 /* This assumes that (VAL & MASK) == 0. */
215 (*cr16_callback
->printf_filtered
)
217 "ERROR at PC 0x%x: ST can only be set when FX is set.\n", PC
);
218 State
.exception
= SIGILL
;
220 /* keep an up-to-date psw around for tracing. */
221 State
.trace
.psw
= (State
.trace
.psw
& mask
) | val
;
226 /* only issue an update if the register is being changed. */
227 if ((State
.cregs
[cr
] & ~mask
) != val
)
228 SLOT_PEND_MASK (State
.cregs
[cr
], mask
, val
);
233 static void trace_input_func
PARAMS ((char *name
,
238 #define trace_input(name, in1, in2, in3) do { if (cr16_debug) trace_input_func (name, in1, in2, in3); } while (0)
240 #ifndef SIZE_INSTRUCTION
241 #define SIZE_INSTRUCTION 8
244 #ifndef SIZE_OPERANDS
245 #define SIZE_OPERANDS 18
249 #define SIZE_VALUES 13
252 #ifndef SIZE_LOCATION
253 #define SIZE_LOCATION 20
260 #ifndef SIZE_LINE_NUMBER
261 #define SIZE_LINE_NUMBER 2
265 trace_input_func (name
, in1
, in2
, in3
)
278 const char *filename
;
279 const char *functionname
;
280 unsigned int linenumber
;
283 if ((cr16_debug
& DEBUG_TRACE
) == 0)
286 switch (State
.ins_type
)
289 case INS_UNKNOWN
: type
= " ?"; break;
292 if ((cr16_debug
& DEBUG_LINE_NUMBER
) == 0)
293 (*cr16_callback
->printf_filtered
) (cr16_callback
,
295 SIZE_PC
, (unsigned)PC
,
297 SIZE_INSTRUCTION
, name
);
302 byte_pc
= decode_pc ();
303 if (text
&& byte_pc
>= text_start
&& byte_pc
< text_end
)
305 filename
= (const char *)0;
306 functionname
= (const char *)0;
308 if (bfd_find_nearest_line (prog_bfd
, text
, (struct bfd_symbol
**)0, byte_pc
- text_start
,
309 &filename
, &functionname
, &linenumber
))
314 sprintf (p
, "#%-*d ", SIZE_LINE_NUMBER
, linenumber
);
319 sprintf (p
, "%-*s ", SIZE_LINE_NUMBER
+1, "---");
320 p
+= SIZE_LINE_NUMBER
+2;
325 sprintf (p
, "%s ", functionname
);
330 char *q
= strrchr (filename
, '/');
331 sprintf (p
, "%s ", (q
) ? q
+1 : filename
);
340 (*cr16_callback
->printf_filtered
) (cr16_callback
,
341 "0x%.*x %s: %-*.*s %-*s ",
342 SIZE_PC
, (unsigned)PC
,
344 SIZE_LOCATION
, SIZE_LOCATION
, buf
,
345 SIZE_INSTRUCTION
, name
);
353 for (i
= 0; i
< 3; i
++)
364 sprintf (p
, "%sr%d", comma
, OP
[i
]);
370 case OP_PROC_REG_OUTPUT
:
371 sprintf (p
, "%scr%d", comma
, OP
[i
]);
377 sprintf (p
, "%s%d", comma
, OP
[i
]);
383 sprintf (p
, "%s%d", comma
, SEXT4(OP
[i
]));
389 sprintf (p
, "%s%d", comma
, SEXT3(OP
[i
]));
395 sprintf (p
, "%s@r%d", comma
, OP
[i
]);
401 sprintf (p
, "%s@(%d,r%d)", comma
, (int16
)OP
[i
], OP
[i
+1]);
407 sprintf (p
, "%s@%d", comma
, OP
[i
]);
414 if ((cr16_debug
& DEBUG_VALUES
) == 0)
418 (*cr16_callback
->printf_filtered
) (cr16_callback
, "%s", buf
);
423 (*cr16_callback
->printf_filtered
) (cr16_callback
, "%-*s", SIZE_OPERANDS
, buf
);
426 for (i
= 0; i
< 3; i
++)
432 (*cr16_callback
->printf_filtered
) (cr16_callback
, "%*s", SIZE_VALUES
, "");
437 case OP_PROC_REG_OUTPUT
:
438 (*cr16_callback
->printf_filtered
) (cr16_callback
, "%*s", SIZE_VALUES
, "---");
442 (*cr16_callback
->printf_filtered
) (cr16_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
443 (uint16
) GPR (OP
[i
]));
447 tmp
= (long)((((uint32
) GPR (OP
[i
])) << 16) | ((uint32
) GPR (OP
[i
] + 1)));
448 (*cr16_callback
->printf_filtered
) (cr16_callback
, "%*s0x%.8lx", SIZE_VALUES
-10, "", tmp
);
452 (*cr16_callback
->printf_filtered
) (cr16_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
453 (uint16
) CREG (OP
[i
]));
457 (*cr16_callback
->printf_filtered
) (cr16_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
462 (*cr16_callback
->printf_filtered
) (cr16_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
463 (uint16
)SEXT4(OP
[i
]));
467 (*cr16_callback
->printf_filtered
) (cr16_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
468 (uint16
)SEXT3(OP
[i
]));
472 (*cr16_callback
->printf_filtered
) (cr16_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
474 (*cr16_callback
->printf_filtered
) (cr16_callback
, "%*s0x%.4x", SIZE_VALUES
-6, "",
475 (uint16
)GPR (OP
[i
+ 1]));
482 (*cr16_callback
->flush_stdout
) (cr16_callback
);
486 do_trace_output_flush (void)
488 (*cr16_callback
->flush_stdout
) (cr16_callback
);
492 do_trace_output_finish (void)
494 (*cr16_callback
->printf_filtered
) (cr16_callback
,
495 " F0=%d F1=%d C=%d\n",
496 (State
.trace
.psw
& PSR_F_BIT
) != 0,
497 (State
.trace
.psw
& PSR_F_BIT
) != 0,
498 (State
.trace
.psw
& PSR_C_BIT
) != 0);
499 (*cr16_callback
->flush_stdout
) (cr16_callback
);
503 trace_output_40 (uint64 val
)
505 if ((cr16_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
507 (*cr16_callback
->printf_filtered
) (cr16_callback
,
508 " :: %*s0x%.2x%.8lx",
511 ((int)(val
>> 32) & 0xff),
512 ((unsigned long) val
) & 0xffffffff);
513 do_trace_output_finish ();
518 trace_output_32 (uint32 val
)
520 if ((cr16_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
522 (*cr16_callback
->printf_filtered
) (cr16_callback
,
527 do_trace_output_finish ();
532 trace_output_16 (uint16 val
)
534 if ((cr16_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
536 (*cr16_callback
->printf_filtered
) (cr16_callback
,
541 do_trace_output_finish ();
548 if ((cr16_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
550 (*cr16_callback
->printf_filtered
) (cr16_callback
, "\n");
551 do_trace_output_flush ();
558 if ((cr16_debug
& (DEBUG_TRACE
| DEBUG_VALUES
)) == (DEBUG_TRACE
| DEBUG_VALUES
))
560 (*cr16_callback
->printf_filtered
) (cr16_callback
,
564 do_trace_output_finish ();
572 #define trace_input(NAME, IN1, IN2, IN3)
573 #define trace_output(RESULT)
581 uint8 a
= OP
[0] & 0xff;
582 uint16 b
= (GPR (OP
[1])) & 0xff;
583 trace_input ("addub", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
584 tmp
= (a
+ b
) & 0xff;
585 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
586 trace_output_16 (tmp
);
594 uint8 a
= ((OP
[0]) & 0xff), b
= (GPR (OP
[1])) & 0xff;
595 trace_input ("addub", OP_CONSTANT16
, OP_REG
, OP_VOID
);
596 tmp
= (a
+ b
) & 0xff;
597 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
598 trace_output_16 (tmp
);
605 uint8 a
= (GPR (OP
[0])) & 0xff;
606 uint8 b
= (GPR (OP
[1])) & 0xff;
607 uint16 tmp
= (a
+ b
) & 0xff;
608 trace_input ("addub", OP_REG
, OP_REG
, OP_VOID
);
609 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
610 trace_output_16 (tmp
);
618 uint16 b
= GPR (OP
[1]);
619 uint16 tmp
= (a
+ b
);
620 trace_input ("adduw", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
621 SET_GPR (OP
[1], tmp
);
622 trace_output_16 (tmp
);
630 uint16 b
= GPR (OP
[1]);
631 uint16 tmp
= (a
+ b
);
632 trace_input ("adduw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
633 SET_GPR (OP
[1], tmp
);
634 trace_output_16 (tmp
);
641 uint16 a
= GPR (OP
[0]);
642 uint16 b
= GPR (OP
[1]);
643 uint16 tmp
= (a
+ b
);
644 trace_input ("adduw", OP_REG
, OP_REG
, OP_VOID
);
645 SET_GPR (OP
[1], tmp
);
646 trace_output_16 (tmp
);
654 uint8 b
= (GPR (OP
[1]) & 0xff);
655 trace_input ("addb", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
656 uint16 tmp
= (a
+ b
) & 0xff;
657 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
658 SET_PSR_C (tmp
> 0xFF);
659 SET_PSR_F (((a
& 0x80) == (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
660 trace_output_16 (tmp
);
667 uint8 a
= (OP
[0]) & 0xff;
668 uint8 b
= (GPR (OP
[1]) & 0xff);
669 trace_input ("addb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
670 uint16 tmp
= (a
+ b
) & 0xff;
671 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
672 SET_PSR_C (tmp
> 0xFF);
673 SET_PSR_F (((a
& 0x80) == (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
674 trace_output_16 (tmp
);
681 uint8 a
= (GPR (OP
[0]) & 0xff);
682 uint8 b
= (GPR (OP
[1]) & 0xff);
683 trace_input ("addb", OP_REG
, OP_REG
, OP_VOID
);
684 uint16 tmp
= (a
+ b
) & 0xff;
685 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
686 SET_PSR_C (tmp
> 0xFF);
687 SET_PSR_F (((a
& 0x80) == (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
688 trace_output_16 (tmp
);
696 uint16 tmp
, b
= GPR (OP
[1]);
697 trace_input ("addw", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
699 SET_GPR (OP
[1], tmp
);
700 SET_PSR_C (tmp
> 0xFFFF);
701 SET_PSR_F (((a
& 0x8000) == (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
702 trace_output_16 (tmp
);
710 uint16 tmp
, b
= GPR (OP
[1]);
712 trace_input ("addw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
713 SET_GPR (OP
[1], tmp
);
714 SET_PSR_C (tmp
> 0xFFFF);
715 SET_PSR_F (((a
& 0x8000) == (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
716 trace_output_16 (tmp
);
723 uint16 tmp
, a
= (GPR (OP
[0])), b
= (GPR (OP
[1]));
724 trace_input ("addw", OP_REG
, OP_REG
, OP_VOID
);
726 SET_GPR (OP
[1], tmp
);
727 SET_PSR_C (tmp
> 0xFFFF);
728 SET_PSR_F (((a
& 0x8000) == (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
729 trace_output_16 (tmp
);
736 uint8 tmp
, a
= OP
[0] & 0xff, b
= (GPR (OP
[1])) & 0xff;
737 trace_input ("addcb", OP_CONSTANT4_1
, OP_REG
, OP_REG
);
738 tmp
= (a
+ b
+ PSR_C
) & 0xff;
739 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
740 SET_PSR_C (tmp
> 0xFF);
741 SET_PSR_F (((a
& 0x80) == (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
742 trace_output_16 (tmp
);
749 int8 a
= OP
[0] & 0xff;
750 uint8 b
= (GPR (OP
[1])) & 0xff;
751 trace_input ("addcb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
752 uint8 tmp
= (a
+ b
+ PSR_C
) & 0xff;
753 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
754 SET_PSR_C (tmp
> 0xFF);
755 SET_PSR_F (((a
& 0x80) == (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
756 trace_output_16 (tmp
);
763 uint8 a
= (GPR (OP
[0])) & 0xff;
764 uint8 b
= (GPR (OP
[1])) & 0xff;
765 trace_input ("addcb", OP_REG
, OP_REG
, OP_VOID
);
766 uint8 tmp
= (a
+ b
+ PSR_C
) & 0xff;
767 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
768 SET_PSR_C (tmp
> 0xFF);
769 SET_PSR_F (((a
& 0x80) == (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
770 trace_output_16 (tmp
);
778 uint16 b
= GPR (OP
[1]);
779 trace_input ("addcw", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
780 uint16 tmp
= (a
+ b
+ PSR_C
);
781 SET_GPR (OP
[1], tmp
);
782 SET_PSR_C (tmp
> 0xFFFF);
783 SET_PSR_F (((a
& 0x8000) == (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
784 trace_output_16 (tmp
);
792 uint16 b
= GPR (OP
[1]);
793 trace_input ("addcw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
794 uint16 tmp
= (a
+ b
+ PSR_C
);
795 SET_GPR (OP
[1], tmp
);
796 SET_PSR_C (tmp
> 0xFFFF);
797 SET_PSR_F (((a
& 0x8000) == (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
798 trace_output_16 (tmp
);
805 uint16 a
= GPR (OP
[1]);
806 uint16 b
= GPR (OP
[1]);
807 trace_input ("addcw", OP_REG
, OP_REG
, OP_VOID
);
808 uint16 tmp
= (a
+ b
+ PSR_C
);
809 SET_GPR (OP
[1], tmp
);
810 SET_PSR_C (tmp
> 0xFFFF);
811 SET_PSR_F (((a
& 0x8000) == (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
812 trace_output_16 (tmp
);
820 uint32 b
= GPR32 (OP
[1]);
821 trace_input ("addd", OP_CONSTANT4_1
, OP_REGP
, OP_VOID
);
822 uint32 tmp
= (a
+ b
);
823 SET_GPR32 (OP
[1], tmp
);
824 SET_PSR_C (tmp
> 0xFFFFFFFF);
825 SET_PSR_F (((a
& 0x80000000) == (b
& 0x80000000)) && ((b
& 0x80000000) != (tmp
& 0x80000000)));
826 trace_output_32 (tmp
);
833 int32 a
= (SEXT16(OP
[0]));
834 uint32 b
= GPR32 (OP
[1]);
835 trace_input ("addd", OP_CONSTANT16
, OP_REGP
, OP_VOID
);
836 uint32 tmp
= (a
+ b
);
837 SET_GPR32 (OP
[1], tmp
);
838 SET_PSR_C (tmp
> 0xFFFFFFFF);
839 SET_PSR_F (((a
& 0x80000000) == (b
& 0x80000000)) && ((b
& 0x80000000) != (tmp
& 0x80000000)));
840 trace_output_32 (tmp
);
847 uint32 a
= GPR32 (OP
[0]);
848 uint32 b
= GPR32 (OP
[1]);
849 trace_input ("addd", OP_REGP
, OP_REGP
, OP_VOID
);
850 uint32 tmp
= (a
+ b
);
851 SET_GPR32 (OP
[1], tmp
);
852 trace_output_32 (tmp
);
853 SET_PSR_C (tmp
> 0xFFFFFFFF);
854 SET_PSR_F (((a
& 0x80000000) == (b
& 0x80000000)) && ((b
& 0x80000000) != (tmp
& 0x80000000)));
862 uint32 b
= GPR32 (OP
[1]);
864 trace_input ("addd", OP_CONSTANT20
, OP_REGP
, OP_VOID
);
866 SET_GPR32 (OP
[1], tmp
);
867 SET_PSR_C (tmp
> 0xFFFFFFFF);
868 SET_PSR_F (((a
& 0x80000000) == (b
& 0x80000000)) && ((b
& 0x80000000) != (tmp
& 0x80000000)));
869 trace_output_32 (tmp
);
877 uint32 b
= GPR32 (OP
[1]);
879 trace_input ("addd", OP_CONSTANT32
, OP_REGP
, OP_VOID
);
881 SET_GPR32 (OP
[1], tmp
);
882 SET_PSR_C (tmp
> 0xFFFFFFFF);
883 SET_PSR_F (((a
& 0x80000000) == (b
& 0x80000000)) && ((b
& 0x80000000) != (tmp
& 0x80000000)));
884 trace_output_32 (tmp
);
891 uint8 tmp
, a
= (OP
[0]) & 0xff, b
= (GPR (OP
[1])) & 0xff;
892 trace_input ("andb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
894 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
895 trace_output_16 (tmp
);
902 uint8 tmp
, a
= (OP
[0]) & 0xff, b
= (GPR (OP
[1])) & 0xff;
903 trace_input ("andb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
905 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
906 trace_output_16 (tmp
);
913 uint8 tmp
, a
= (GPR (OP
[0])) & 0xff, b
= (GPR (OP
[1])) & 0xff;
914 trace_input ("andb", OP_REG
, OP_REG
, OP_VOID
);
916 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
917 trace_output_16 (tmp
);
924 uint16 tmp
, a
= OP
[0], b
= GPR (OP
[1]);
925 trace_input ("andw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
927 SET_GPR (OP
[1], tmp
);
928 trace_output_16 (tmp
);
935 uint16 tmp
, a
= OP
[0], b
= GPR (OP
[1]);
936 trace_input ("andw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
938 SET_GPR (OP
[1], tmp
);
939 trace_output_16 (tmp
);
946 uint16 tmp
, a
= GPR (OP
[0]), b
= GPR (OP
[1]);
947 trace_input ("andw", OP_REG
, OP_REG
, OP_VOID
);
949 SET_GPR (OP
[1], tmp
);
950 trace_output_16 (tmp
);
957 uint32 tmp
, a
= OP
[0], b
= GPR32 (OP
[1]);
958 trace_input ("andd", OP_CONSTANT32
, OP_REGP
, OP_VOID
);
960 SET_GPR32 (OP
[1], tmp
);
961 trace_output_32 (tmp
);
968 uint32 tmp
, a
= (GPR32 (OP
[0])), b
= (GPR32 (OP
[1]));
969 trace_input ("andd", OP_REGP
, OP_REGP
, OP_VOID
);
971 SET_GPR32 (OP
[1], tmp
);
972 trace_output_32 (tmp
);
979 uint32 tmp
, a
= (OP
[0]), b
= GPR32 (OP
[1]);
980 trace_input ("ord", OP_CONSTANT32
, OP_REG
, OP_VOID
);
982 SET_GPR32 (OP
[1], tmp
);
983 trace_output_32 (tmp
);
990 uint32 tmp
, a
= GPR32 (OP
[0]), b
= GPR32 (OP
[1]);
991 trace_input ("ord", OP_REGP
, OP_REGP
, OP_VOID
);
993 SET_GPR32 (OP
[1], tmp
);
994 trace_output_32 (tmp
);
1001 uint32 tmp
, a
= (OP
[0]), b
= GPR32 (OP
[1]);
1002 trace_input ("xord", OP_CONSTANT32
, OP_REG
, OP_VOID
);
1004 SET_GPR32 (OP
[1], tmp
);
1005 trace_output_32 (tmp
);
1012 uint32 tmp
, a
= GPR32 (OP
[0]), b
= GPR32 (OP
[1]);
1013 trace_input ("xord", OP_REGP
, OP_REGP
, OP_VOID
);
1015 SET_GPR32 (OP
[1], tmp
);
1016 trace_output_32 (tmp
);
1024 uint32 tmp
, cc
= cond_stat (OP
[0]);
1025 trace_input ("b", OP_CONSTANT4
, OP_DISPE9
, OP_VOID
);
1029 tmp
= (PC
- (OP
[1]));
1031 tmp
= (PC
+ (OP
[1]));
1032 /* If the resulting PC value is less than 0x00_0000 or greater
1033 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1035 if ((tmp
< 0x000000) || (tmp
> 0xFFFFFF))
1037 State
.exception
= SIG_CR16_BUS
;
1038 State
.pc_changed
= 1; /* Don't increment the PC. */
1039 trace_output_void ();
1045 sign_flag
= 0; /* Reset sign_flag. */
1046 trace_output_32 (tmp
);
1053 uint32 tmp
, cc
= cond_stat (OP
[0]);
1054 trace_input ("b", OP_CONSTANT4
, OP_DISP17
, OP_VOID
);
1061 /* If the resulting PC value is less than 0x00_0000 or greater
1062 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1064 if ((tmp
< 0x000000) || (tmp
> 0xFFFFFF))
1066 State
.exception
= SIG_CR16_BUS
;
1067 State
.pc_changed
= 1; /* Don't increment the PC. */
1068 trace_output_void ();
1074 sign_flag
= 0; /* Reset sign_flag. */
1075 trace_output_32 (tmp
);
1082 uint32 tmp
, cc
= cond_stat (OP
[0]);
1083 trace_input ("b", OP_CONSTANT4
, OP_DISP25
, OP_VOID
);
1087 tmp
= (PC
- (OP
[1]));
1089 tmp
= (PC
+ (OP
[1]));
1090 /* If the resulting PC value is less than 0x00_0000 or greater
1091 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1093 if ((tmp
< 0x000000) || (tmp
> 0xFFFFFF))
1095 State
.exception
= SIG_CR16_BUS
;
1096 State
.pc_changed
= 1; /* Don't increment the PC. */
1097 trace_output_void ();
1103 sign_flag
= 0; /* Reset sign_flag. */
1104 trace_output_32 (tmp
);
1112 trace_input ("bal", OP_REG
, OP_DISP17
, OP_VOID
);
1113 tmp
= ((PC
+ 4) >> 1); /* Store PC in RA register. */
1114 SET_GPR32 (14, tmp
);
1116 tmp
= (PC
- (OP
[1]));
1118 tmp
= (PC
+ (OP
[1]));
1120 /* If the resulting PC value is less than 0x00_0000 or greater
1121 than 0xFF_FFFF, this instruction causes an IAD trap. */
1123 if ((tmp
< 0x000000) || (tmp
> 0xFFFFFF))
1125 State
.exception
= SIG_CR16_BUS
;
1126 State
.pc_changed
= 1; /* Don't increment the PC. */
1127 trace_output_void ();
1132 sign_flag
= 0; /* Reset sign_flag. */
1133 trace_output_32 (tmp
);
1142 trace_input ("bal", OP_REGP
, OP_DISP25
, OP_VOID
);
1143 tmp
= (((PC
) + 4) >> 1); /* Store PC in reg pair. */
1144 SET_GPR32 (OP
[0], tmp
);
1146 tmp
= ((PC
) - (OP
[1]));
1148 tmp
= ((PC
) + (OP
[1]));
1149 /* If the resulting PC value is less than 0x00_0000 or greater
1150 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1152 if ((tmp
< 0x000000) || (tmp
> 0xFFFFFF))
1154 State
.exception
= SIG_CR16_BUS
;
1155 State
.pc_changed
= 1; /* Don't increment the PC. */
1156 trace_output_void ();
1161 sign_flag
= 0; /* Reset sign_flag. */
1162 trace_output_32 (tmp
);
1170 trace_input ("jal", OP_REGP
, OP_REGP
, OP_VOID
);
1171 SET_GPR32 (OP
[0], (((PC
) + 4) >> 1)); /* Store next PC in RA */
1172 tmp
= GPR32 (OP
[1]);
1173 tmp
= SEXT24(tmp
<< 1);
1174 /* If the resulting PC value is less than 0x00_0000 or greater
1175 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1177 if ((tmp
< 0x0) || (tmp
> 0xFFFFFF))
1179 State
.exception
= SIG_CR16_BUS
;
1180 State
.pc_changed
= 1; /* Don't increment the PC. */
1181 trace_output_void ();
1187 trace_output_32 (tmp
);
1196 trace_input ("jal", OP_REGP
, OP_VOID
, OP_VOID
);
1197 SET_GPR32 (14, (((PC
) + 2) >> 1)); /* Store next PC in RA */
1198 tmp
= GPR32 (OP
[0]);
1199 tmp
= SEXT24(tmp
<< 1);
1200 /* If the resulting PC value is less than 0x00_0000 or greater
1201 than 0xFF_FFFF, this instruction causes an IAD trap.*/
1203 if ((tmp
< 0x0) || (tmp
> 0xFFFFFF))
1205 State
.exception
= SIG_CR16_BUS
;
1206 State
.pc_changed
= 1; /* Don't increment the PC. */
1207 trace_output_void ();
1213 trace_output_32 (tmp
);
1222 uint8 a
= (GPR (OP
[0]) & 0xFF);
1223 trace_input ("beq0b", OP_REG
, OP_DISP5
, OP_VOID
);
1228 addr
= (PC
- OP
[1]);
1230 addr
= (PC
+ OP
[1]);
1234 sign_flag
= 0; /* Reset sign_flag. */
1235 trace_output_void ();
1243 uint8 a
= (GPR (OP
[0]) & 0xFF);
1244 trace_input ("bne0b", OP_REG
, OP_DISP5
, OP_VOID
);
1249 addr
= (PC
- OP
[1]);
1251 addr
= (PC
+ OP
[1]);
1255 sign_flag
= 0; /* Reset sign_flag. */
1256 trace_output_void ();
1264 uint16 a
= GPR (OP
[0]);
1265 trace_input ("beq0w", OP_REG
, OP_DISP5
, OP_VOID
);
1270 addr
= (PC
- OP
[1]);
1272 addr
= (PC
+ OP
[1]);
1276 sign_flag
= 0; /* Reset sign_flag. */
1277 trace_output_void ();
1285 uint16 a
= GPR (OP
[0]);
1286 trace_input ("bne0w", OP_REG
, OP_DISP5
, OP_VOID
);
1291 addr
= (PC
- OP
[1]);
1293 addr
= (PC
+ OP
[1]);
1297 sign_flag
= 0; /* Reset sign_flag. */
1298 trace_output_void ();
1307 trace_input ("jeq", OP_REGP
, OP_VOID
, OP_VOID
);
1310 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits. */
1311 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit. */
1313 trace_output_32 (tmp
);
1321 trace_input ("jne", OP_REGP
, OP_VOID
, OP_VOID
);
1324 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits. */
1325 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit. */
1327 trace_output_32 (tmp
);
1335 trace_input ("jcs", OP_REGP
, OP_VOID
, OP_VOID
);
1338 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1339 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1341 trace_output_32 (tmp
);
1349 trace_input ("jcc", OP_REGP
, OP_VOID
, OP_VOID
);
1352 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1353 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1355 trace_output_32 (tmp
);
1363 trace_input ("jhi", OP_REGP
, OP_VOID
, OP_VOID
);
1366 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1367 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1369 trace_output_32 (tmp
);
1377 trace_input ("jls", OP_REGP
, OP_VOID
, OP_VOID
);
1380 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1381 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1383 trace_output_32 (tmp
);
1391 trace_input ("jgt", OP_REGP
, OP_VOID
, OP_VOID
);
1394 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1395 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1397 trace_output_32 (tmp
);
1405 trace_input ("jle", OP_REGP
, OP_VOID
, OP_VOID
);
1408 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1409 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1411 trace_output_32 (tmp
);
1420 trace_input ("jfs", OP_REGP
, OP_VOID
, OP_VOID
);
1423 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1424 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1426 trace_output_32 (tmp
);
1434 trace_input ("jfc", OP_REGP
, OP_VOID
, OP_VOID
);
1437 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1438 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1440 trace_output_32 (tmp
);
1448 trace_input ("jlo", OP_REGP
, OP_VOID
, OP_VOID
);
1449 if (((PSR_Z
) == 0) & ((PSR_L
) == 0))
1451 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1452 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1454 trace_output_32 (tmp
);
1462 trace_input ("jhs", OP_REGP
, OP_VOID
, OP_VOID
);
1463 if (((PSR_Z
) == 1) | ((PSR_L
) == 1))
1465 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1466 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1468 trace_output_32 (tmp
);
1476 trace_input ("jlt", OP_REGP
, OP_VOID
, OP_VOID
);
1477 if (((PSR_Z
) == 0) & ((PSR_N
) == 0))
1479 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1480 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1482 trace_output_32 (tmp
);
1490 trace_input ("jge", OP_REGP
, OP_VOID
, OP_VOID
);
1491 if (((PSR_Z
) == 1) | ((PSR_N
) == 1))
1493 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1494 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1496 trace_output_32 (tmp
);
1504 trace_input ("jump", OP_REGP
, OP_VOID
, OP_VOID
);
1505 tmp
= GPR32 (OP
[0]) /*& 0x3fffff*/; /* Use only 0 - 22 bits */
1506 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1507 trace_output_32 (tmp
);
1515 trace_input ("jusr", OP_REGP
, OP_VOID
, OP_VOID
);
1516 tmp
= (GPR32 (OP
[0])) & 0x3fffff; /* Use only 0 - 22 bits */
1517 JMP (tmp
<< 1); /* Set PC's 1 - 23 bits and clear 0th bit*/
1519 trace_output_32 (tmp
);
1526 trace_input ("seq", OP_REG
, OP_VOID
, OP_VOID
);
1531 trace_output_void ();
1537 trace_input ("sne", OP_REG
, OP_VOID
, OP_VOID
);
1542 trace_output_void ();
1549 trace_input ("scs", OP_REG
, OP_VOID
, OP_VOID
);
1554 trace_output_void ();
1561 trace_input ("scc", OP_REG
, OP_VOID
, OP_VOID
);
1566 trace_output_void ();
1573 trace_input ("shi", OP_REG
, OP_VOID
, OP_VOID
);
1578 trace_output_void ();
1585 trace_input ("sls", OP_REG
, OP_VOID
, OP_VOID
);
1590 trace_output_void ();
1597 trace_input ("sgt", OP_REG
, OP_VOID
, OP_VOID
);
1602 trace_output_void ();
1609 trace_input ("sle", OP_REG
, OP_VOID
, OP_VOID
);
1614 trace_output_void ();
1621 trace_input ("sfs", OP_REG
, OP_VOID
, OP_VOID
);
1626 trace_output_void ();
1633 trace_input ("sfc", OP_REG
, OP_VOID
, OP_VOID
);
1638 trace_output_void ();
1646 trace_input ("slo", OP_REG
, OP_VOID
, OP_VOID
);
1647 if (((PSR_Z
) == 0) & ((PSR_L
) == 0))
1651 trace_output_void ();
1658 trace_input ("shs", OP_REG
, OP_VOID
, OP_VOID
);
1659 if ( ((PSR_Z
) == 1) | ((PSR_L
) == 1))
1663 trace_output_void ();
1670 trace_input ("slt", OP_REG
, OP_VOID
, OP_VOID
);
1671 if (((PSR_Z
) == 0) & ((PSR_N
) == 0))
1675 trace_output_void ();
1682 trace_input ("sge", OP_REG
, OP_VOID
, OP_VOID
);
1683 if (((PSR_Z
) == 1) | ((PSR_N
) == 1))
1687 trace_output_void ();
1694 uint8 a
= OP
[0] & 0xff;
1695 uint32 addr
= OP
[1], tmp
;
1696 trace_input ("cbitb", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
1698 SET_PSR_F (tmp
& (1 << a
));
1699 tmp
= tmp
& ~(1 << a
);
1701 trace_output_32 (tmp
);
1708 uint8 a
= OP
[0] & 0xff;
1709 uint32 addr
= OP
[1], tmp
;
1710 trace_input ("cbitb", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
1712 SET_PSR_F (tmp
& (1 << a
));
1713 tmp
= tmp
& ~(1 << a
);
1715 trace_output_32 (tmp
);
1722 uint8 a
= (OP
[0]) & 0xff;
1723 uint32 addr
= (GPR (OP
[2])) + OP
[1], tmp
;
1724 trace_input ("cbitb", OP_CONSTANT4
, OP_R_INDEX7_ABS20
, OP_VOID
);
1726 SET_PSR_F (tmp
& (1 << a
));
1727 tmp
= tmp
& ~(1 << a
);
1729 trace_output_32 (addr
);
1736 uint8 a
= (OP
[0]) & 0xff;
1737 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1738 trace_input ("cbitb", OP_CONSTANT4
, OP_RP_INDEX_DISP14
, OP_VOID
);
1740 SET_PSR_F (tmp
& (1 << a
));
1741 tmp
= tmp
& ~(1 << a
);
1743 trace_output_32 (addr
);
1750 uint8 a
= (OP
[0]) & 0xff;
1751 uint32 addr
= (GPR (OP
[2])) + OP
[1], tmp
;
1752 trace_input ("cbitb", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
1754 SET_PSR_F (tmp
& (1 << a
));
1755 tmp
= tmp
& ~(1 << a
);
1757 trace_output_32 (addr
);
1764 uint8 a
= (OP
[0]) & 0xff;
1765 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1766 trace_input ("cbitb", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
1768 SET_PSR_F (tmp
& (1 << a
));
1769 tmp
= tmp
& ~(1 << a
);
1771 trace_output_32 (addr
);
1778 uint8 a
= (OP
[0]) & 0xff;
1779 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1780 trace_input ("cbitb", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
1782 SET_PSR_F (tmp
& (1 << a
));
1783 tmp
= tmp
& ~(1 << a
);
1785 trace_output_32 (addr
);
1793 uint8 a
= (OP
[0]) & 0xff;
1794 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1795 trace_input ("cbitb", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
1797 SET_PSR_F (tmp
& (1 << a
));
1798 tmp
= tmp
& ~(1 << a
);
1800 trace_output_32 (addr
);
1807 uint8 a
= (OP
[0]) & 0xff;
1808 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1809 trace_input ("cbitb", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
1811 SET_PSR_F (tmp
& (1 << a
));
1812 tmp
= tmp
& ~(1 << a
);
1814 trace_output_32 (addr
);
1823 uint32 addr
= OP
[1], tmp
;
1824 trace_input ("cbitw", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
1826 SET_PSR_F (tmp
& (1 << a
));
1827 tmp
= tmp
& ~(1 << a
);
1829 trace_output_32 (tmp
);
1837 uint32 addr
= OP
[1], tmp
;
1838 trace_input ("cbitw", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
1840 SET_PSR_F (tmp
& (1 << a
));
1841 tmp
= tmp
& ~(1 << a
);
1843 trace_output_32 (tmp
);
1851 uint16 a
= (OP
[0]), tmp
;
1852 trace_input ("cbitw", OP_CONSTANT4
, OP_R_INDEX8_ABS20
, OP_VOID
);
1855 addr
= (GPR32 (12)) + OP
[2];
1857 addr
= (GPR32 (13)) + OP
[2];
1860 SET_PSR_F (tmp
& (1 << a
));
1861 tmp
= tmp
& ~(1 << a
);
1863 trace_output_32 (addr
);
1872 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1873 trace_input ("cbitw", OP_CONSTANT4
, OP_RP_INDEX_DISP14
, OP_VOID
);
1875 SET_PSR_F (tmp
& (1 << a
));
1876 tmp
= tmp
& ~(1 << a
);
1878 trace_output_32 (addr
);
1886 uint32 addr
= (GPR (OP
[2])) + OP
[1], tmp
;
1887 trace_input ("cbitw", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
1889 SET_PSR_F (tmp
& (1 << a
));
1890 tmp
= tmp
& ~(1 << a
);
1892 trace_output_32 (addr
);
1901 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1902 trace_input ("cbitw", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
1904 SET_PSR_F (tmp
& (1 << a
));
1905 tmp
= tmp
& ~(1 << a
);
1907 trace_output_32 (addr
);
1915 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1916 trace_input ("cbitw", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
1918 SET_PSR_F (tmp
& (1 << a
));
1919 tmp
= tmp
& ~(1 << a
);
1921 trace_output_32 (addr
);
1930 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1931 trace_input ("cbitw", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
1933 SET_PSR_F (tmp
& (1 << a
));
1934 tmp
= tmp
& ~(1 << a
);
1936 trace_output_32 (addr
);
1944 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
1945 trace_input ("cbitw", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
1947 SET_PSR_F (tmp
& (1 << a
));
1948 tmp
= tmp
& ~(1 << a
);
1950 trace_output_32 (addr
);
1957 uint8 a
= OP
[0] & 0xff;
1958 uint32 addr
= OP
[1], tmp
;
1959 trace_input ("sbitb", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
1961 SET_PSR_F (tmp
& (1 << a
));
1962 tmp
= tmp
| (1 << a
);
1964 trace_output_32 (tmp
);
1971 uint8 a
= OP
[0] & 0xff;
1972 uint32 addr
= OP
[1], tmp
;
1973 trace_input ("sbitb", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
1975 SET_PSR_F (tmp
& (1 << a
));
1976 tmp
= tmp
| (1 << a
);
1978 trace_output_32 (tmp
);
1985 uint8 a
= OP
[0] & 0xff;
1986 uint32 addr
= (GPR (OP
[2])) + OP
[1], tmp
;
1987 trace_input ("sbitb", OP_CONSTANT4
, OP_R_INDEX7_ABS20
, OP_VOID
);
1989 SET_PSR_F (tmp
& (1 << a
));
1990 tmp
= tmp
| (1 << a
);
1992 trace_output_32 (tmp
);
1999 uint8 a
= OP
[0] & 0xff;
2000 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2001 trace_input ("sbitb", OP_CONSTANT4
, OP_RP_INDEX_DISP14
, OP_VOID
);
2003 SET_PSR_F (tmp
& (1 << a
));
2004 tmp
= tmp
| (1 << a
);
2006 trace_output_32 (tmp
);
2013 uint8 a
= OP
[0] & 0xff;
2014 uint32 addr
= (GPR (OP
[2])) + OP
[1], tmp
;
2015 trace_input ("sbitb", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
2017 SET_PSR_F (tmp
& (1 << a
));
2018 tmp
= tmp
| (1 << a
);
2020 trace_output_32 (tmp
);
2028 uint8 a
= OP
[0] & 0xff;
2029 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2030 trace_input ("sbitb", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
2032 SET_PSR_F (tmp
& (1 << a
));
2033 tmp
= tmp
| (1 << a
);
2035 trace_output_32 (tmp
);
2042 uint8 a
= OP
[0] & 0xff;
2043 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2044 trace_input ("sbitb", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
2046 SET_PSR_F (tmp
& (1 << a
));
2047 tmp
= tmp
| (1 << a
);
2049 trace_output_32 (tmp
);
2057 uint8 a
= OP
[0] & 0xff;
2058 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2059 trace_input ("sbitb", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
2061 SET_PSR_F (tmp
& (1 << a
));
2062 tmp
= tmp
| (1 << a
);
2064 trace_output_32 (tmp
);
2072 uint8 a
= OP
[0] & 0xff;
2073 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2074 trace_input ("sbitb", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
2076 SET_PSR_F (tmp
& (1 << a
));
2077 tmp
= tmp
| (1 << a
);
2079 trace_output_32 (tmp
);
2088 uint32 addr
= OP
[1], tmp
;
2089 trace_input ("sbitw", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
2091 SET_PSR_F (tmp
& (1 << a
));
2092 tmp
= tmp
| (1 << a
);
2094 trace_output_32 (tmp
);
2102 uint32 addr
= OP
[1], tmp
;
2103 trace_input ("sbitw", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
2105 SET_PSR_F (tmp
& (1 << a
));
2106 tmp
= tmp
| (1 << a
);
2108 trace_output_32 (tmp
);
2116 uint16 a
= (OP
[0]), tmp
;
2117 trace_input ("sbitw", OP_CONSTANT4
, OP_R_INDEX8_ABS20
, OP_VOID
);
2120 addr
= (GPR32 (12)) + OP
[2];
2122 addr
= (GPR32 (13)) + OP
[2];
2125 SET_PSR_F (tmp
& (1 << a
));
2126 tmp
= tmp
| (1 << a
);
2128 trace_output_32 (addr
);
2136 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2137 trace_input ("sbitw", OP_CONSTANT4
, OP_RP_INDEX_DISP14
, OP_VOID
);
2139 SET_PSR_F (tmp
& (1 << a
));
2140 tmp
= tmp
| (1 << a
);
2142 trace_output_32 (addr
);
2150 uint32 addr
= (GPR (OP
[2])) + OP
[1], tmp
;
2151 trace_input ("sbitw", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
2153 SET_PSR_F (tmp
& (1 << a
));
2154 tmp
= tmp
| (1 << a
);
2156 trace_output_32 (addr
);
2164 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2165 trace_input ("sbitw", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
2167 SET_PSR_F (tmp
& (1 << a
));
2168 tmp
= tmp
| (1 << a
);
2170 trace_output_32 (addr
);
2178 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2179 trace_input ("sbitw", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
2181 SET_PSR_F (tmp
& (1 << a
));
2182 tmp
= tmp
| (1 << a
);
2184 trace_output_32 (addr
);
2192 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2193 trace_input ("sbitw", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
2195 SET_PSR_F (tmp
& (1 << a
));
2196 tmp
= tmp
| (1 << a
);
2198 trace_output_32 (addr
);
2206 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2207 trace_input ("sbitw", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
2209 SET_PSR_F (tmp
& (1 << a
));
2210 tmp
= tmp
| (1 << a
);
2212 trace_output_32 (addr
);
2220 uint8 a
= OP
[0] & 0xff;
2221 uint32 addr
= OP
[1], tmp
;
2222 trace_input ("tbitb", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
2224 SET_PSR_F (tmp
& (1 << a
));
2225 trace_output_32 (tmp
);
2232 uint8 a
= OP
[0] & 0xff;
2233 uint32 addr
= OP
[1], tmp
;
2234 trace_input ("tbitb", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
2236 SET_PSR_F (tmp
& (1 << a
));
2237 trace_output_32 (tmp
);
2244 uint8 a
= (OP
[0]) & 0xff;
2245 uint32 addr
= (GPR (OP
[2])) + OP
[1], tmp
;
2246 trace_input ("tbitb", OP_CONSTANT4
, OP_R_INDEX7_ABS20
, OP_VOID
);
2248 SET_PSR_F (tmp
& (1 << a
));
2249 trace_output_32 (addr
);
2256 uint8 a
= (OP
[0]) & 0xff;
2257 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2258 trace_input ("tbitb", OP_CONSTANT4
, OP_RP_INDEX_DISP14
, OP_VOID
);
2260 SET_PSR_F (tmp
& (1 << a
));
2261 trace_output_32 (addr
);
2268 uint8 a
= (OP
[0]) & 0xff;
2269 uint32 addr
= (GPR (OP
[2])) + OP
[1], tmp
;
2270 trace_input ("tbitb", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
2272 SET_PSR_F (tmp
& (1 << a
));
2273 trace_output_32 (addr
);
2280 uint8 a
= (OP
[0]) & 0xff;
2281 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2282 trace_input ("tbitb", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
2284 SET_PSR_F (tmp
& (1 << a
));
2285 trace_output_32 (addr
);
2292 uint8 a
= (OP
[0]) & 0xff;
2293 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2294 trace_input ("tbitb", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
2296 SET_PSR_F (tmp
& (1 << a
));
2297 trace_output_32 (addr
);
2304 uint8 a
= (OP
[0]) & 0xff;
2305 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2306 trace_input ("tbitb", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
2308 SET_PSR_F (tmp
& (1 << a
));
2309 trace_output_32 (addr
);
2316 uint8 a
= (OP
[0]) & 0xff;
2317 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2318 trace_input ("tbitb", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
2320 SET_PSR_F (tmp
& (1 << a
));
2321 trace_output_32 (addr
);
2330 uint32 addr
= OP
[1], tmp
;
2331 trace_input ("tbitw", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
2333 SET_PSR_F (tmp
& (1 << a
));
2334 trace_output_32 (tmp
);
2342 uint32 addr
= OP
[1], tmp
;
2343 trace_input ("tbitw", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
2345 SET_PSR_F (tmp
& (1 << a
));
2346 trace_output_32 (tmp
);
2355 uint16 a
= (OP
[0]), tmp
;
2356 trace_input ("tbitw", OP_CONSTANT4
, OP_R_INDEX8_ABS20
, OP_VOID
);
2359 addr
= (GPR32 (12)) + OP
[2];
2361 addr
= (GPR32 (13)) + OP
[2];
2364 SET_PSR_F (tmp
& (1 << a
));
2365 trace_output_32 (addr
);
2373 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2374 trace_input ("tbitw", OP_CONSTANT4
, OP_RP_INDEX_DISP14
, OP_VOID
);
2376 SET_PSR_F (tmp
& (1 << a
));
2377 trace_output_32 (addr
);
2385 uint32 addr
= (GPR (OP
[2])) + OP
[1], tmp
;
2386 trace_input ("tbitw", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
2388 SET_PSR_F (tmp
& (1 << a
));
2389 trace_output_32 (addr
);
2397 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2398 trace_input ("tbitw", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
2400 SET_PSR_F (tmp
& (1 << a
));
2401 trace_output_32 (addr
);
2409 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2410 trace_input ("tbitw", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
2412 SET_PSR_F (tmp
& (1 << a
));
2413 trace_output_32 (addr
);
2421 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2422 trace_input ("tbitw", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
2424 SET_PSR_F (tmp
& (1 << a
));
2425 trace_output_32 (addr
);
2434 uint32 addr
= (GPR32 (OP
[2])) + OP
[1], tmp
;
2435 trace_input ("tbitw", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
2437 SET_PSR_F (tmp
& (1 << a
));
2438 trace_output_32 (addr
);
2447 uint32 addr
= (GPR (OP
[1])), tmp
;
2448 trace_input ("tbit", OP_CONSTANT4
, OP_REG
, OP_VOID
);
2450 SET_PSR_F (tmp
& (1 << a
));
2451 trace_output_32 (tmp
);
2458 uint16 a
= GPR (OP
[0]);
2459 uint32 addr
= (GPR (OP
[1])), tmp
;
2460 trace_input ("tbit", OP_REG
, OP_REG
, OP_VOID
);
2462 SET_PSR_F (tmp
& (1 << a
));
2463 trace_output_32 (tmp
);
2471 uint8 a
= (OP
[0]) & 0xFF;
2472 uint8 b
= (GPR (OP
[1])) & 0xFF;
2473 trace_input ("cmpb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
2475 SET_PSR_N ((int8
)a
> (int8
)b
);
2477 trace_output_flag ();
2484 uint8 a
= (OP
[0]) & 0xFF;
2485 uint8 b
= (GPR (OP
[1])) & 0xFF;
2486 trace_input ("cmpb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
2488 SET_PSR_N ((int8
)a
> (int8
)b
);
2490 trace_output_flag ();
2497 uint8 a
= (GPR (OP
[0])) & 0xFF;
2498 uint8 b
= (GPR (OP
[1])) & 0xFF;
2499 trace_input ("cmpb", OP_REG
, OP_REG
, OP_VOID
);
2501 SET_PSR_N ((int8
)a
> (int8
)b
);
2503 trace_output_flag ();
2511 uint16 b
= GPR (OP
[1]);
2512 trace_input ("cmpw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
2514 SET_PSR_N ((int16
)a
> (int16
)b
);
2516 trace_output_flag ();
2524 uint16 b
= GPR (OP
[1]);
2525 trace_input ("cmpw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
2527 SET_PSR_N ((int16
)a
> (int16
)b
);
2529 trace_output_flag ();
2536 uint16 a
= GPR (OP
[0]) ;
2537 uint16 b
= GPR (OP
[1]) ;
2538 trace_input ("cmpw", OP_REG
, OP_REG
, OP_VOID
);
2540 SET_PSR_N ((int16
)a
> (int16
)b
);
2542 trace_output_flag ();
2550 uint32 b
= GPR32 (OP
[1]);
2551 trace_input ("cmpd", OP_CONSTANT4
, OP_REGP
, OP_VOID
);
2553 SET_PSR_N ((int32
)a
> (int32
)b
);
2555 trace_output_flag ();
2562 uint32 a
= (SEXT16(OP
[0]));
2563 uint32 b
= GPR32 (OP
[1]);
2564 trace_input ("cmpd", OP_CONSTANT16
, OP_REGP
, OP_VOID
);
2566 SET_PSR_N ((int32
)a
> (int32
)b
);
2568 trace_output_flag ();
2575 uint32 a
= GPR32 (OP
[0]) ;
2576 uint32 b
= GPR32 (OP
[1]) ;
2577 trace_input ("cmpd", OP_REGP
, OP_REGP
, OP_VOID
);
2579 SET_PSR_N ((int32
)a
> (int32
)b
);
2581 trace_output_flag ();
2589 uint32 b
= GPR32 (OP
[1]);
2590 trace_input ("cmpd", OP_CONSTANT32
, OP_REGP
, OP_VOID
);
2592 SET_PSR_N ((int32
)a
> (int32
)b
);
2594 trace_output_flag ();
2602 uint8 tmp
= OP
[0] & 0xFF;
2603 trace_input ("movb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
2604 uint16 a
= (GPR (OP
[1])) & 0xFF00;
2605 SET_GPR (OP
[1], (a
| tmp
));
2606 trace_output_16 (tmp
);
2613 uint8 tmp
= OP
[0] & 0xFF;
2614 trace_input ("movb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
2615 uint16 a
= (GPR (OP
[1])) & 0xFF00;
2616 SET_GPR (OP
[1], (a
| tmp
));
2617 trace_output_16 (tmp
);
2624 uint8 tmp
= (GPR (OP
[0])) & 0xFF;
2625 trace_input ("movb", OP_REG
, OP_REG
, OP_VOID
);
2626 uint16 a
= (GPR (OP
[1])) & 0xFF00;
2627 SET_GPR (OP
[1], (a
| tmp
));
2628 trace_output_16 (tmp
);
2636 trace_input ("movw", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
2637 SET_GPR (OP
[1], (tmp
& 0xffff));
2638 trace_output_16 (tmp
);
2646 trace_input ("movw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
2647 SET_GPR (OP
[1], (tmp
& 0xffff));
2648 trace_output_16 (tmp
);
2655 uint16 tmp
= GPR (OP
[0]);
2656 trace_input ("movw", OP_REG
, OP_REGP
, OP_VOID
);
2657 uint32 a
= GPR32 (OP
[1]);
2658 a
= (a
& 0xffff0000) | tmp
;
2659 SET_GPR32 (OP
[1], a
);
2660 trace_output_16 (tmp
);
2667 uint8 tmp
= (GPR (OP
[0])) & 0xFF;
2668 trace_input ("movxb", OP_REG
, OP_REG
, OP_VOID
);
2669 SET_GPR (OP
[1], ((SEXT8(tmp
)) & 0xffff));
2670 trace_output_16 (tmp
);
2677 uint8 tmp
= (GPR (OP
[0])) & 0xFF;
2678 trace_input ("movzb", OP_REG
, OP_REG
, OP_VOID
);
2679 SET_GPR (OP
[1], tmp
);
2680 trace_output_16 (tmp
);
2687 uint16 tmp
= GPR (OP
[0]);
2688 trace_input ("movxw", OP_REG
, OP_REGP
, OP_VOID
);
2689 SET_GPR32 (OP
[1], SEXT16(tmp
));
2690 trace_output_16 (tmp
);
2697 uint16 tmp
= GPR (OP
[0]);
2698 trace_input ("movzw", OP_REG
, OP_REGP
, OP_VOID
);
2699 SET_GPR32 (OP
[1], (tmp
& 0x0000FFFF));
2700 trace_output_16 (tmp
);
2708 trace_input ("movd", OP_CONSTANT4
, OP_REGP
, OP_VOID
);
2709 SET_GPR32 (OP
[1], tmp
);
2710 trace_output_32 (tmp
);
2717 int32 tmp
= SEXT16(OP
[0]);
2718 trace_input ("movd", OP_CONSTANT16
, OP_REGP
, OP_VOID
);
2719 SET_GPR32 (OP
[1], tmp
);
2720 trace_output_32 (tmp
);
2727 uint32 tmp
= GPR32 (OP
[0]);
2728 trace_input ("movd", OP_REGP
, OP_REGP
, OP_VOID
);
2729 SET_GPR32 (OP
[1], tmp
);
2730 trace_output_32 (tmp
);
2738 trace_input ("movd", OP_CONSTANT20
, OP_REGP
, OP_VOID
);
2739 SET_GPR32 (OP
[1], tmp
);
2740 trace_output_32 (tmp
);
2748 trace_input ("movd", OP_CONSTANT32
, OP_REGP
, OP_VOID
);
2749 SET_GPR32 (OP
[1], tmp
);
2750 trace_output_32 (tmp
);
2757 uint32 addr
= GPR (0);
2758 uint16 count
= OP
[0], reg
= 2, tmp
;
2759 trace_input ("loadm", OP_CONSTANT4
, OP_VOID
, OP_VOID
);
2762 State
.exception
= SIG_CR16_BUS
;
2763 State
.pc_changed
= 1; /* Don't increment the PC. */
2764 trace_output_void ();
2775 if (reg
== 6) reg
= 8;
2779 trace_output_void ();
2787 uint32 addr
= GPR32 (0);
2788 uint16 count
= OP
[0], reg
= 2, tmp
;
2789 trace_input ("loadm", OP_CONSTANT4
, OP_VOID
, OP_VOID
);
2792 State
.exception
= SIG_CR16_BUS
;
2793 State
.pc_changed
= 1; /* Don't increment the PC. */
2794 trace_output_void ();
2805 if (reg
== 6) reg
= 8;
2808 SET_GPR32 (0, addr
);
2809 trace_output_void ();
2818 * ADDR = zext24(abs20) | remap (ie 0xF00000)
2821 * If (abs20 > 0xEFFFF) the resulting address is logically ORed
2822 * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
2823 * by the core to 16M-64k to 16M. */
2825 uint16 tmp
, a
= (GPR (OP
[1])) & 0xFF00;
2826 uint32 addr
= OP
[0];
2827 trace_input ("loadb", OP_ABS20
, OP_REG
, OP_VOID
);
2828 if (addr
> 0xEFFFF) addr
|= 0xF00000;
2830 SET_GPR (OP
[1], (a
| tmp
));
2831 trace_output_16 (tmp
);
2842 uint16 tmp
, a
= (GPR (OP
[1])) & 0xFF00;
2843 uint32 addr
= OP
[0];
2844 trace_input ("loadb", OP_ABS24
, OP_REG
, OP_VOID
);
2846 SET_GPR (OP
[1], (a
| tmp
));
2847 trace_output_16 (tmp
);
2854 /* loadb [Rindex]ABS20 REG
2855 * ADDR = Rindex + zext24(disp20)
2859 uint16 tmp
, a
= (GPR (OP
[2])) & 0xFF00;
2860 trace_input ("loadb", OP_R_INDEX8_ABS20
, OP_REG
, OP_VOID
);
2863 addr
= (GPR32 (12)) + OP
[1];
2865 addr
= (GPR32 (13)) + OP
[1];
2868 SET_GPR (OP
[2], (a
| tmp
));
2869 trace_output_16 (tmp
);
2877 /* loadb DIPS4(REGP) REG
2878 * ADDR = RPBASE + zext24(DISP4)
2880 uint16 tmp
, a
= (GPR (OP
[2])) & 0xFF00;
2881 uint32 addr
= (GPR32 (OP
[1])) + OP
[0];
2882 trace_input ("loadb", OP_RP_BASE_DISP4
, OP_REG
, OP_VOID
);
2884 SET_GPR (OP
[2], (a
| tmp
));
2885 trace_output_16 (tmp
);
2892 /* loadb [Rindex]disp0(RPbasex) REG
2893 * ADDR = Rpbasex + Rindex
2897 uint16 tmp
, a
= (GPR (OP
[3])) & 0xFF00;
2898 trace_input ("loadb", OP_RP_INDEX_DISP0
, OP_REG
, OP_VOID
);
2900 addr
= (GPR32 (OP
[2])) + OP
[1];
2903 addr
= (GPR32 (12)) + addr
;
2905 addr
= (GPR32 (13)) + addr
;
2908 SET_GPR (OP
[3], (a
| tmp
));
2909 trace_output_16 (tmp
);
2916 /* loadb [Rindex]disp14(RPbasex) REG
2917 * ADDR = Rpbasex + Rindex + zext24(disp14)
2921 uint16 tmp
, a
= (GPR (OP
[3])) & 0xFF00;
2923 addr
= (GPR32 (OP
[2])) + OP
[1];
2926 addr
= (GPR32 (12)) + addr
;
2928 addr
= (GPR32 (13)) + addr
;
2930 trace_input ("loadb", OP_RP_INDEX_DISP14
, OP_REG
, OP_VOID
);
2932 SET_GPR (OP
[3], (a
| tmp
));
2933 trace_output_16 (tmp
);
2941 /* loadb DISPE20(REG) REG
2942 * zext24(Rbase) + zext24(dispe20)
2945 uint16 tmp
,a
= (GPR (OP
[2])) & 0xFF00;
2946 uint32 addr
= OP
[0] + (GPR (OP
[1]));
2947 trace_input ("loadb", OP_R_BASE_DISPE20
, OP_REG
, OP_VOID
);
2949 SET_GPR (OP
[2], (a
| tmp
));
2950 trace_output_16 (tmp
);
2957 /* loadb DISP20(REG) REG
2958 * ADDR = zext24(Rbase) + zext24(disp20)
2961 uint16 tmp
,a
= (GPR (OP
[2])) & 0xFF00;
2962 uint32 addr
= OP
[0] + (GPR (OP
[1]));
2963 trace_input ("loadb", OP_R_BASE_DISP20
, OP_REG
, OP_VOID
);
2965 SET_GPR (OP
[2], (a
| tmp
));
2966 trace_output_16 (tmp
);
2973 /* loadb disp16(REGP) REG
2974 * ADDR = RPbase + zext24(disp16)
2977 uint16 tmp
,a
= (GPR (OP
[2])) & 0xFF00;
2978 uint32 addr
= (GPR32 (OP
[1])) + OP
[0];
2979 trace_input ("loadb", OP_RP_BASE_DISP16
, OP_REG
, OP_VOID
);
2981 SET_GPR (OP
[2], (a
| tmp
));
2982 trace_output_16 (tmp
);
2989 /* loadb disp20(REGP) REG
2990 * ADDR = RPbase + zext24(disp20)
2992 uint16 tmp
,a
= (GPR (OP
[2])) & 0xFF00;
2993 uint32 addr
= (GPR32 (OP
[1])) + OP
[0];
2994 trace_input ("loadb", OP_RP_BASE_DISP20
, OP_REG
, OP_VOID
);
2996 SET_GPR (OP
[2], (a
| tmp
));
2997 trace_output_16 (tmp
);
3005 /* loadb -disp20(REGP) REG
3006 * ADDR = RPbase + zext24(-disp20)
3008 uint16 tmp
,a
= (GPR (OP
[2])) & 0xFF00;
3009 uint32 addr
= (GPR32 (OP
[1])) + OP
[1];
3010 trace_input ("loadb", OP_RP_BASE_DISPE20
, OP_REG
, OP_VOID
);
3012 SET_GPR (OP
[2], (a
| tmp
));
3013 trace_output_16 (tmp
);
3020 /* loadb [Rindex]disp20(RPbasexb) REG
3021 * ADDR = RPbasex + Rindex + zext24(disp20)
3025 uint16 tmp
, a
= (GPR (OP
[3])) & 0xFF00;
3026 trace_input ("loadb", OP_RP_INDEX_DISP20
, OP_REG
, OP_VOID
);
3028 addr
= (GPR32 (OP
[2])) + OP
[1];
3031 addr
= (GPR32 (12)) + addr
;
3033 addr
= (GPR32 (13)) + addr
;
3036 SET_GPR (OP
[3], (a
| tmp
));
3037 trace_output_16 (tmp
);
3046 * ADDR = zext24(abs20) | remap
3049 * If (abs20 > 0xEFFFF) the resulting address is logically ORed
3050 * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
3051 * by the core to 16M-64k to 16M. */
3054 uint32 addr
= OP
[0];
3055 trace_input ("loadw", OP_ABS20
, OP_REG
, OP_VOID
);
3056 if (addr
> 0xEFFFF) addr
|= 0xF00000;
3058 SET_GPR (OP
[1], tmp
);
3059 trace_output_16 (tmp
);
3071 uint32 addr
= OP
[0];
3072 trace_input ("loadw", OP_ABS24
, OP_REG
, OP_VOID
);
3074 SET_GPR (OP
[1], tmp
);
3075 trace_output_16 (tmp
);
3082 /* loadw [Rindex]ABS20 REG
3083 * ADDR = Rindex + zext24(disp20)
3088 trace_input ("loadw", OP_R_INDEX8_ABS20
, OP_REG
, OP_VOID
);
3091 addr
= (GPR32 (12)) + OP
[1];
3093 addr
= (GPR32 (13)) + OP
[1];
3096 SET_GPR (OP
[2], tmp
);
3097 trace_output_16 (tmp
);
3105 /* loadw DIPS4(REGP) REGP
3106 * ADDR = RPBASE + zext24(DISP4)
3110 trace_input ("loadw", OP_RP_BASE_DISP4
, OP_REG
, OP_VOID
);
3111 addr
= (GPR32 (OP
[1])) + OP
[0];
3115 a
= (GPR32 (OP
[2])) & 0xffff0000;
3116 SET_GPR32 (OP
[2], (a
| tmp
));
3119 SET_GPR (OP
[2], tmp
);
3121 trace_output_16 (tmp
);
3129 /* loadw [Rindex]disp0(RPbasex) REG
3130 * ADDR = Rpbasex + Rindex
3135 trace_input ("loadw", OP_RP_INDEX_DISP0
, OP_REG
, OP_VOID
);
3137 addr
= (GPR32 (OP
[2])) + OP
[1];
3140 addr
= (GPR32 (12)) + addr
;
3142 addr
= (GPR32 (13)) + addr
;
3145 SET_GPR (OP
[3], tmp
);
3146 trace_output_16 (tmp
);
3154 /* loadw [Rindex]disp14(RPbasex) REG
3155 * ADDR = Rpbasex + Rindex + zext24(disp14)
3160 trace_input ("loadw", OP_RP_INDEX_DISP14
, OP_REG
, OP_VOID
);
3161 addr
= (GPR32 (OP
[2])) + OP
[1];
3164 addr
= (GPR32 (12)) + addr
;
3166 addr
= (GPR32 (13)) + addr
;
3169 SET_GPR (OP
[3], tmp
);
3170 trace_output_16 (tmp
);
3177 /* loadw dispe20(REG) REGP
3178 * REGP = [DISPE20+[REG]] */
3182 trace_input ("loadw", OP_R_BASE_DISPE20
, OP_REGP
, OP_VOID
);
3183 addr
= OP
[0] + (GPR (OP
[1]));
3187 a
= (GPR32 (OP
[2])) & 0xffff0000;
3188 SET_GPR32 (OP
[2], (a
| tmp
));
3191 SET_GPR (OP
[2], tmp
);
3193 trace_output_16 (tmp
);
3201 /* loadw DISP20(REG) REGP
3202 * ADDR = zext24(Rbase) + zext24(disp20)
3207 trace_input ("loadw", OP_R_BASE_DISP20
, OP_REGP
, OP_VOID
);
3208 addr
= OP
[0] + (GPR (OP
[1]));
3212 a
= (GPR32 (OP
[2])) & 0xffff0000;
3213 SET_GPR32 (OP
[2], (a
| tmp
));
3216 SET_GPR (OP
[2], tmp
);
3218 trace_output_16 (tmp
);
3225 /* loadw disp16(REGP) REGP
3226 * ADDR = RPbase + zext24(disp16)
3230 trace_input ("loadw", OP_RP_BASE_DISP16
, OP_REGP
, OP_VOID
);
3231 addr
= (GPR32 (OP
[1])) + OP
[0];
3235 a
= (GPR32 (OP
[2])) & 0xffff0000;
3236 SET_GPR32 (OP
[2], (a
| tmp
));
3239 SET_GPR (OP
[2], tmp
);
3241 trace_output_16 (tmp
);
3248 /* loadw disp20(REGP) REGP
3249 * ADDR = RPbase + zext24(disp20)
3253 trace_input ("loadw", OP_RP_BASE_DISP20
, OP_REG
, OP_VOID
);
3254 addr
= (GPR32 (OP
[1])) + OP
[0];
3258 a
= (GPR32 (OP
[2])) & 0xffff0000;
3259 SET_GPR32 (OP
[2], (a
| tmp
));
3262 SET_GPR (OP
[2], tmp
);
3264 trace_output_16 (tmp
);
3271 /* loadw -disp20(REGP) REG
3272 * ADDR = RPbase + zext24(-disp20)
3277 trace_input ("loadw", OP_RP_BASE_DISPE20
, OP_REG
, OP_VOID
);
3278 addr
= (GPR32 (OP
[1])) + OP
[0];
3282 a
= (GPR32 (OP
[2])) & 0xffff0000;
3283 SET_GPR32 (OP
[2], (a
| tmp
));
3286 SET_GPR (OP
[2], tmp
);
3288 trace_output_16 (tmp
);
3296 /* loadw [Rindex]disp20(RPbasexb) REG
3297 * ADDR = RPbasex + Rindex + zext24(disp20)
3302 trace_input ("loadw", OP_RP_INDEX_DISP20
, OP_REG
, OP_VOID
);
3305 addr
= (GPR32 (12)) + OP
[1] + (GPR32 (OP
[2]));
3307 addr
= (GPR32 (13)) + OP
[1] + (GPR32 (OP
[2]));
3310 SET_GPR (OP
[3], tmp
);
3311 trace_output_16 (tmp
);
3319 /* loadd ABS20, REGP
3320 * ADDR = zext24(abs20) | remap
3323 * If (abs20 > 0xEFFFF) the resulting address is logically ORed
3324 * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
3325 * by the core to 16M-64k to 16M. */
3329 trace_input ("loadd", OP_ABS20
, OP_REGP
, OP_VOID
);
3330 if (addr
> 0xEFFFF) addr
|= 0xF00000;
3332 tmp
= ((tmp
<< 16) & 0xffff)| ((tmp
>> 16) & 0xffff);
3333 SET_GPR32 (OP
[1], tmp
);
3334 trace_output_32 (tmp
);
3341 /* loadd ABS24, REGP
3345 uint32 addr
= OP
[0];
3347 trace_input ("loadd", OP_ABS24
, OP_REGP
, OP_VOID
);
3349 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3350 SET_GPR32 (OP
[1],tmp
);
3351 trace_output_32 (tmp
);
3359 /* loadd [Rindex]ABS20 REGP
3360 * ADDR = Rindex + zext24(disp20)
3364 trace_input ("loadd", OP_R_INDEX8_ABS20
, OP_REGP
, OP_VOID
);
3367 addr
= (GPR32 (12)) + OP
[1];
3369 addr
= (GPR32 (13)) + OP
[1];
3372 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3373 SET_GPR32 (OP
[2], tmp
);
3374 trace_output_32 (tmp
);
3382 /* loadd dips4(regp) REGP
3383 * ADDR = Rpbase + zext24(disp4)
3386 uint32 tmp
, addr
= (GPR32 (OP
[1])) + OP
[0];
3387 trace_input ("loadd", OP_RP_BASE_DISP4
, OP_REGP
, OP_VOID
);
3389 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3390 SET_GPR32 (OP
[2], tmp
);
3391 trace_output_32 (tmp
);
3399 /* loadd [Rindex]disp0(RPbasex) REGP
3400 * ADDR = Rpbasex + Rindex
3404 trace_input ("loadd", OP_RP_INDEX_DISP0
, OP_REGP
, OP_VOID
);
3407 addr
= (GPR32 (12)) + (GPR32 (OP
[2])) + OP
[1];
3409 addr
= (GPR32 (13)) + (GPR32 (OP
[2])) + OP
[1];
3412 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3413 SET_GPR32 (OP
[3], tmp
);
3414 trace_output_32 (tmp
);
3422 /* loadd [Rindex]disp14(RPbasex) REGP
3423 * ADDR = Rpbasex + Rindex + zext24(disp14)
3427 trace_input ("loadd", OP_RP_INDEX_DISP14
, OP_REGP
, OP_VOID
);
3430 addr
= (GPR32 (12)) + OP
[1] + (GPR32 (OP
[2]));
3432 addr
= (GPR32 (13)) + OP
[1] + (GPR32 (OP
[2]));
3435 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3436 SET_GPR (OP
[3],tmp
);
3437 trace_output_32 (tmp
);
3445 /* loadd dispe20(REG) REG
3446 * zext24(Rbase) + zext24(dispe20)
3449 uint32 tmp
, addr
= OP
[0] + (GPR (OP
[1]));
3450 trace_input ("loadd", OP_R_BASE_DISPE20
, OP_REGP
, OP_VOID
);
3452 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3453 SET_GPR32 (OP
[2], tmp
);
3454 trace_output_32 (tmp
);
3462 /* loadd DISP20(REG) REG
3463 * ADDR = zext24(Rbase) + zext24(disp20)
3466 uint32 tmp
, addr
= OP
[0] + (GPR (OP
[1]));
3467 trace_input ("loadd", OP_R_BASE_DISP20
, OP_REGP
, OP_VOID
);
3469 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3470 SET_GPR32 (OP
[2], tmp
);
3471 trace_output_32 (tmp
);
3478 /* loadd disp16(REGP) REGP
3479 * ADDR = RPbase + zext24(disp16)
3481 uint32 tmp
, addr
= OP
[0] + (GPR32 (OP
[1]));
3482 trace_input ("loadd", OP_RP_BASE_DISP16
, OP_REGP
, OP_VOID
);
3484 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3485 SET_GPR32 (OP
[2], tmp
);
3486 trace_output_32 (tmp
);
3494 /* loadd disp20(REGP) REGP
3495 * ADDR = RPbase + zext24(disp20)
3497 uint32 tmp
, addr
= OP
[0] + (GPR32 (OP
[1]));
3498 trace_input ("loadd", OP_RP_BASE_DISP20
, OP_REGP
, OP_VOID
);
3500 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3501 SET_GPR32 (OP
[2], tmp
);
3502 trace_output_32 (tmp
);
3509 /* loadd -disp20(REGP) REGP
3510 * ADDR = RPbase + zext24(-disp20)
3513 uint32 tmp
, addr
= OP
[0] + (GPR32 (OP
[1]));
3514 trace_input ("loadd", OP_RP_BASE_DISPE20
, OP_REGP
, OP_VOID
);
3516 tmp
= ((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff);
3517 SET_GPR32 (OP
[2], tmp
);
3518 trace_output_32 (tmp
);
3525 /* loadd [Rindex]disp20(RPbasexb) REGP
3526 * ADDR = RPbasex + Rindex + zext24(disp20)
3530 trace_input ("loadd", OP_RP_INDEX_DISP20
, OP_REGP
, OP_VOID
);
3533 addr
= (GPR32 (12)) + OP
[1] + (GPR32 (OP
[2]));
3535 addr
= (GPR32 (13)) + OP
[1] + (GPR32 (OP
[2]));
3538 tmp
= ((tmp
<< 16) & 0xffff)| ((tmp
>> 16) & 0xffff);
3539 SET_GPR32 (OP
[3], tmp
);
3540 trace_output_32 (tmp
);
3549 * ADDR = zext24(abs20) | remap
3552 * If (abs20 > 0xEFFFF) the resulting address is logically ORed
3553 * with 0xF00000 i.e. addresses from 1M-64k to 1M are re-mapped
3554 * by the core to 16M-64k to 16M. */
3556 uint8 a
= ((GPR (OP
[0])) & 0xff);
3557 uint32 addr
= OP
[1];
3558 trace_input ("storb", OP_REG
, OP_ABS20_OUTPUT
, OP_VOID
);
3560 trace_output_32 (addr
);
3571 uint8 a
= ((GPR (OP
[0])) & 0xff);
3572 uint32 addr
= OP
[1];
3573 trace_input ("storb", OP_REG
, OP_ABS24_OUTPUT
, OP_VOID
);
3575 trace_output_32 (addr
);
3582 /* storb REG, [Rindex]ABS20
3583 * ADDR = Rindex + zext24(disp20)
3587 uint8 a
= ((GPR (OP
[0])) & 0xff);
3588 trace_input ("storb", OP_REG
, OP_R_INDEX8_ABS20
, OP_VOID
);
3591 addr
= (GPR32 (12)) + OP
[2];
3593 addr
= (GPR32 (13)) + OP
[2];
3596 trace_output_32 (addr
);
3603 /* storb REG, DIPS4(REGP)
3604 * ADDR = RPBASE + zext24(DISP4)
3607 uint16 a
= ((GPR (OP
[0])) & 0xff);
3608 trace_input ("storb", OP_REG
, OP_RP_BASE_DISPE4
, OP_VOID
);
3609 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3611 trace_output_32 (addr
);
3618 /* storb [Rindex]disp0(RPbasex) REG
3619 * ADDR = Rpbasex + Rindex
3623 uint8 a
= ((GPR (OP
[0])) & 0xff);
3624 trace_input ("storb", OP_REG
, OP_RP_INDEX_DISP0
, OP_VOID
);
3627 addr
= (GPR32 (12)) + (GPR32 (OP
[3])) + OP
[2];
3629 addr
= (GPR32 (13)) + (GPR32 (OP
[3])) + OP
[2];
3632 trace_output_32 (addr
);
3639 /* storb REG, [Rindex]disp14(RPbasex)
3640 * ADDR = Rpbasex + Rindex + zext24(disp14)
3643 uint8 a
= ((GPR (OP
[0])) & 0xff);
3644 trace_input ("storb", OP_REG
, OP_RP_INDEX_DISP14
, OP_VOID
);
3645 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3647 trace_output_32 (addr
);
3654 /* storb REG, DISPE20(REG)
3655 * zext24(Rbase) + zext24(dispe20)
3658 uint8 a
= ((GPR (OP
[0])) & 0xff);
3659 trace_input ("storb", OP_REG
, OP_R_BASE_DISPE20
, OP_VOID
);
3660 uint32 addr
= OP
[1] + (GPR (OP
[2]));
3662 trace_output_32 (addr
);
3669 /* storb REG, DISP20(REG)
3670 * ADDR = zext24(Rbase) + zext24(disp20)
3673 uint8 a
= (GPR (OP
[0]) & 0xff);
3674 trace_input ("storb", OP_REG
, OP_R_BASE_DISPS20
, OP_VOID
);
3675 uint32 addr
= OP
[1] + (GPR (OP
[2]));
3677 trace_output_32 (addr
);
3684 /* storb REG, disp16(REGP)
3685 * ADDR = RPbase + zext24(disp16)
3688 uint8 a
= ((GPR (OP
[0])) & 0xff);
3689 trace_input ("storb", OP_REG
, OP_RP_BASE_DISP16
, OP_VOID
);
3690 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3692 trace_output_32 (addr
);
3699 /* storb REG, disp20(REGP)
3700 * ADDR = RPbase + zext24(disp20)
3703 uint8 a
= ((GPR (OP
[0])) & 0xff);
3704 trace_input ("storb", OP_REG
, OP_RP_BASE_DISPS20
, OP_VOID
);
3705 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3707 trace_output_32 (addr
);
3714 /* storb REG, -disp20(REGP)
3715 * ADDR = RPbase + zext24(-disp20)
3718 uint8 a
= (GPR (OP
[0]) & 0xff);
3719 trace_input ("storb", OP_REG
, OP_RP_BASE_DISPE20
, OP_VOID
);
3720 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3722 trace_output_32 (addr
);
3729 /* storb REG, [Rindex]disp20(RPbase)
3730 * ADDR = RPbasex + Rindex + zext24(disp20)
3733 uint8 a
= (GPR (OP
[0])) & 0xff;
3734 trace_input ("storb", OP_REG
, OP_RP_INDEX_DISPS20
, OP_VOID
);
3735 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3737 trace_output_32 (addr
);
3740 /* STR_IMM instructions. */
3745 uint8 a
= (OP
[0]) & 0xff;
3746 trace_input ("storb", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
3747 uint32 addr
= OP
[1];
3749 trace_output_32 (addr
);
3756 uint8 a
= (OP
[0]) & 0xff;
3757 trace_input ("storb", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
3758 uint32 addr
= OP
[1];
3760 trace_output_32 (addr
);
3768 uint8 a
= (OP
[0]) & 0xff;
3769 trace_input ("storb", OP_CONSTANT4
, OP_R_INDEX8_ABS20
, OP_VOID
);
3772 addr
= (GPR32 (12)) + OP
[2];
3774 addr
= (GPR32 (13)) + OP
[2];
3777 trace_output_32 (addr
);
3784 uint8 a
= (OP
[0]) & 0xff;
3785 trace_input ("storb", OP_CONSTANT4
, OP_RP_BASE_DISP14
, OP_VOID
);
3786 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3788 trace_output_32 (addr
);
3795 uint8 a
= (OP
[0]) & 0xff;
3796 trace_input ("storb", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
3797 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3799 trace_output_32 (addr
);
3806 uint8 a
= (OP
[0]) & 0xff;
3807 trace_input ("storb", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
3808 uint32 addr
= (GPR (OP
[2])) + OP
[1];
3810 trace_output_32 (addr
);
3817 uint8 a
= (OP
[0]) & 0xff;
3818 trace_input ("storb", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
3819 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3821 trace_output_32 (addr
);
3828 uint8 a
= (OP
[0]) & 0xff;
3829 trace_input ("storb", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
3830 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3832 trace_output_32 (addr
);
3839 uint8 a
= (OP
[0]) & 0xff;
3840 trace_input ("storb", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
3841 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3843 trace_output_32 (addr
);
3845 /* endif for STR_IMM. */
3851 uint16 a
= GPR (OP
[0]);
3852 trace_input ("storw", OP_REG
, OP_ABS20_OUTPUT
, OP_VOID
);
3853 uint32 addr
= OP
[1];
3855 trace_output_32 (addr
);
3862 uint16 a
= GPR (OP
[0]);
3863 trace_input ("storw", OP_REG
, OP_ABS24_OUTPUT
, OP_VOID
);
3864 uint32 addr
= OP
[1];
3866 trace_output_32 (addr
);
3874 uint16 a
= GPR (OP
[0]);
3875 trace_input ("storw", OP_REG
, OP_R_INDEX8_ABS20
, OP_VOID
);
3878 addr
= (GPR32 (12)) + OP
[2];
3880 addr
= (GPR32 (13)) + OP
[2];
3883 trace_output_32 (addr
);
3891 uint16 a
= (GPR (OP
[0]));
3892 trace_input ("storw", OP_REGP
, OP_RP_BASE_DISPE4
, OP_VOID
);
3893 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3895 trace_output_32 (addr
);
3902 uint16 a
= GPR (OP
[0]);
3903 trace_input ("storw", OP_REG
, OP_RP_INDEX_DISP0
, OP_VOID
);
3904 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3906 trace_output_32 (addr
);
3913 uint16 a
= GPR (OP
[0]);
3914 trace_input ("storw", OP_REG
, OP_RP_INDEX_DISP14
, OP_VOID
);
3915 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3917 trace_output_32 (addr
);
3924 uint16 a
= (GPR (OP
[0]));
3925 trace_input ("storw", OP_REGP
, OP_RP_BASE_DISPE20
, OP_VOID
);
3926 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3928 trace_output_32 (addr
);
3935 uint16 a
= (GPR (OP
[0]));
3936 trace_input ("storw", OP_REG
, OP_R_BASE_DISPS20
, OP_VOID
);
3937 uint32 addr
= (GPR (OP
[2])) + OP
[1];
3939 trace_output_32 (addr
);
3946 uint16 a
= (GPR (OP
[0]));
3947 trace_input ("storw", OP_REG
, OP_RP_BASE_DISP16
, OP_VOID
);
3948 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3950 trace_output_32 (addr
);
3957 uint16 a
= (GPR (OP
[0]));
3958 trace_input ("storw", OP_REG
, OP_RP_BASE_DISPS20
, OP_VOID
);
3959 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3961 trace_output_32 (addr
);
3968 uint16 a
= (GPR (OP
[0]));
3969 trace_input ("storw", OP_REG
, OP_RP_BASE_DISPE20
, OP_VOID
);
3970 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3972 trace_output_32 (addr
);
3979 uint16 a
= (GPR (OP
[0]));
3980 trace_input ("storw", OP_REG
, OP_RP_INDEX_DISPS20
, OP_VOID
);
3981 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
3983 trace_output_32 (addr
);
3986 /* STORE-w IMM instruction *****/
3992 trace_input ("storw", OP_CONSTANT4
, OP_ABS20_OUTPUT
, OP_VOID
);
3993 uint32 addr
= OP
[1];
3995 trace_output_32 (addr
);
4003 trace_input ("storw", OP_CONSTANT4
, OP_ABS24_OUTPUT
, OP_VOID
);
4004 uint32 addr
= OP
[1];
4006 trace_output_32 (addr
);
4015 trace_input ("storw", OP_CONSTANT4
, OP_R_INDEX8_ABS20
, OP_VOID
);
4018 addr
= (GPR32 (12)) + OP
[2];
4020 addr
= (GPR32 (13)) + OP
[2];
4023 trace_output_32 (addr
);
4031 trace_input ("storw", OP_CONSTANT4
, OP_RP_BASE_DISP14
, OP_VOID
);
4032 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4034 trace_output_32 (addr
);
4042 trace_input ("storw", OP_CONSTANT4
, OP_RP_INDEX_DISP0
, OP_VOID
);
4043 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4045 trace_output_32 (addr
);
4053 trace_input ("storw", OP_CONSTANT4
, OP_R_BASE_DISPS20
, OP_VOID
);
4054 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4056 trace_output_32 (addr
);
4064 trace_input ("storw", OP_CONSTANT4
, OP_RP_BASE_DISP16
, OP_VOID
);
4065 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4067 trace_output_32 (addr
);
4076 trace_input ("storw", OP_CONSTANT4
, OP_RP_BASE_DISPS20
, OP_VOID
);
4077 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4079 trace_output_32 (addr
);
4087 trace_input ("storw", OP_CONSTANT4
, OP_RP_INDEX_DISPS20
, OP_VOID
);
4088 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4090 trace_output_32 (addr
);
4098 uint32 a
= GPR32 (OP
[0]);
4099 trace_input ("stord", OP_REGP
, OP_ABS20_OUTPUT
, OP_VOID
);
4100 uint32 addr
= OP
[1];
4102 trace_output_32 (addr
);
4109 uint32 a
= GPR32 (OP
[0]);
4110 trace_input ("stord", OP_REGP
, OP_ABS24_OUTPUT
, OP_VOID
);
4111 uint32 addr
= OP
[1];
4113 trace_output_32 (addr
);
4120 uint32 addr
, a
= GPR32 (OP
[0]);
4121 trace_input ("stord", OP_REGP
, OP_R_INDEX8_ABS20
, OP_VOID
);
4124 addr
= (GPR32 (12)) + OP
[2];
4126 addr
= (GPR32 (13)) + OP
[2];
4129 trace_output_32 (addr
);
4136 uint32 a
= GPR32 (OP
[0]);
4137 trace_input ("stord", OP_REGP
, OP_RP_BASE_DISPE4
, OP_VOID
);
4138 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4140 trace_output_32 (addr
);
4147 uint32 a
= GPR32 (OP
[0]);
4148 trace_input ("stord", OP_REGP
, OP_RP_INDEX_DISP0
, OP_VOID
);
4149 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4151 trace_output_32 (addr
);
4158 uint32 a
= GPR32 (OP
[0]);
4159 trace_input ("stord", OP_REGP
, OP_RP_INDEX_DISP14
, OP_VOID
);
4160 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4162 trace_output_32 (addr
);
4169 uint32 a
= GPR32 (OP
[0]);
4170 trace_input ("stord", OP_REGP
, OP_R_BASE_DISPE20
, OP_VOID
);
4171 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4173 trace_output_32 (addr
);
4180 uint32 a
= GPR32 (OP
[0]);
4181 trace_input ("stord", OP_REGP
, OP_R_BASE_DISPS20
, OP_VOID
);
4182 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4184 trace_output_32 (addr
);
4191 uint32 a
= GPR32 (OP
[0]);
4192 trace_input ("stord", OP_REGP
, OP_RP_BASE_DISP16
, OP_VOID
);
4193 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4195 trace_output_32 (addr
);
4202 uint32 a
= GPR32 (OP
[0]);
4203 trace_input ("stord", OP_REGP
, OP_RP_BASE_DISPS20
, OP_VOID
);
4204 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4206 trace_output_32 (addr
);
4213 uint32 a
= GPR32 (OP
[0]);
4214 trace_input ("stord", OP_REGP
, OP_RP_BASE_DISPE20
, OP_VOID
);
4215 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4217 trace_output_32 (addr
);
4224 uint32 a
= GPR32 (OP
[0]);
4225 trace_input ("stord", OP_REGP
, OP_RP_INDEX_DISPS20
, OP_VOID
);
4226 uint32 addr
= (GPR32 (OP
[2])) + OP
[1];
4228 trace_output_32 (addr
);
4237 trace_input ("macuw", OP_REG
, OP_REG
, OP_REGP
);
4241 /*REVISIT FOR SATURATION and Q FORMAT. */
4242 SET_GPR32 (OP
[2], tmp
);
4243 trace_output_32 (tmp
);
4252 trace_input ("macuw", OP_REG
, OP_REG
, OP_REGP
);
4256 /*REVISIT FOR SATURATION. */
4257 SET_GPR32 (OP
[2], tmp
);
4258 trace_output_32 (tmp
);
4267 trace_input ("macsw", OP_REG
, OP_REG
, OP_REGP
);
4271 /*REVISIT FOR SATURATION. */
4272 SET_GPR32 (OP
[2], tmp
);
4273 trace_output_32 (tmp
);
4282 int8 a
= (OP
[0]) & 0xff;
4283 int8 b
= (GPR (OP
[1])) & 0xff;
4284 trace_input ("mulb", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
4285 tmp
= (a
* b
) & 0xff;
4286 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
4287 trace_output_16 (tmp
);
4295 int8 a
= (OP
[0]) & 0xff, b
= (GPR (OP
[1])) & 0xff;
4296 trace_input ("mulb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4297 tmp
= (a
* b
) & 0xff;
4298 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
4299 trace_output_16 (tmp
);
4308 int8 a
= (GPR (OP
[0])) & 0xff, b
= (GPR (OP
[1])) & 0xff;
4309 trace_input ("mulb", OP_REG
, OP_REG
, OP_VOID
);
4310 tmp
= (a
* b
) & 0xff;
4311 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
4312 trace_output_16 (tmp
);
4322 int16 b
= (GPR (OP
[1]));
4323 trace_input ("mulw", OP_CONSTANT4_1
, OP_REG
, OP_VOID
);
4324 tmp
= (a
* b
) & 0xffff;
4325 SET_GPR (OP
[1], tmp
);
4326 trace_output_32 (tmp
);
4334 int16 a
= OP
[0], b
= (GPR (OP
[1]));
4335 trace_input ("mulw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4336 tmp
= (a
* b
) & 0xffff;
4337 SET_GPR (OP
[1], tmp
);
4338 trace_output_32 (tmp
);
4347 int16 a
= (GPR (OP
[0])), b
= (GPR (OP
[1]));
4348 trace_input ("mulw", OP_REG
, OP_REG
, OP_VOID
);
4349 tmp
= (a
* b
) & 0xffff;
4350 SET_GPR (OP
[1], tmp
);
4351 trace_output_32 (tmp
);
4360 int8 a
= (GPR (OP
[0])) & 0xff, b
= (GPR (OP
[1])) & 0xff;
4361 trace_input ("mulsb", OP_REG
, OP_REG
, OP_VOID
);
4363 SET_GPR (OP
[1], tmp
);
4364 trace_output_32 (tmp
);
4371 int32 tmp
, b
= (GPR32 (OP
[1]));
4372 int16 a
= (GPR (OP
[0]));
4373 trace_input ("mulsw", OP_REG
, OP_REGP
, OP_VOID
);
4375 SET_GPR32 (OP
[1], tmp
);
4376 trace_output_32 (tmp
);
4383 uint32 tmp
, b
= (GPR32 (OP
[1]));
4384 uint16 a
= (GPR (OP
[0]));
4385 trace_input ("muluw", OP_REG
, OP_REGP
, OP_VOID
);
4387 SET_GPR32 (OP
[1], tmp
);
4388 trace_output_32 (tmp
);
4396 trace_input ("nop", OP_VOID
, OP_VOID
, OP_VOID
);
4399 State
.exception
= SIGTRAP
;
4400 ins_type_counters
[ (int)State
.ins_type
]--; /* don't count nops as normal instructions */
4401 switch (State
.ins_type
)
4404 ins_type_counters
[ (int)INS_UNKNOWN
]++;
4410 trace_output_void ();
4418 uint8 tmp
, a
= (OP
[0]) & 0xff, b
= (GPR (OP
[1])) & 0xff;
4419 trace_input ("orb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4421 SET_GPR (OP
[1], ((GPR (OP
[1]) | tmp
)));
4422 trace_output_16 (tmp
);
4429 uint8 tmp
, a
= (OP
[0]) & 0xff, b
= (GPR (OP
[1])) & 0xff;
4430 trace_input ("orb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
4432 SET_GPR (OP
[1], ((GPR (OP
[1]) | tmp
)));
4433 trace_output_16 (tmp
);
4440 uint8 tmp
, a
= (GPR (OP
[0])) & 0xff, b
= (GPR (OP
[1])) & 0xff;
4441 trace_input ("orb", OP_REG
, OP_REG
, OP_VOID
);
4443 SET_GPR (OP
[1], ((GPR (OP
[1]) | tmp
)));
4444 trace_output_16 (tmp
);
4451 uint16 tmp
, a
= (OP
[0]), b
= (GPR (OP
[1]));
4452 trace_input ("orw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4454 SET_GPR (OP
[1], tmp
);
4455 trace_output_16 (tmp
);
4463 uint16 tmp
, a
= (OP
[0]), b
= (GPR (OP
[1]));
4464 trace_input ("orw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
4466 SET_GPR (OP
[1], tmp
);
4467 trace_output_16 (tmp
);
4474 uint16 tmp
, a
= (GPR (OP
[0])), b
= (GPR (OP
[1]));
4475 trace_input ("orw", OP_REG
, OP_REG
, OP_VOID
);
4477 SET_GPR (OP
[1], tmp
);
4478 trace_output_16 (tmp
);
4487 uint16 tmp
, b
= (GPR (OP
[1])) & 0xFF;
4488 trace_input ("lshb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4489 /* A positive count specifies a shift to the left;
4490 * A negative count specifies a shift to the right. */
4496 sign_flag
= 0; /* Reset sign_flag. */
4498 SET_GPR (OP
[1], ((tmp
& 0xFF) | ((GPR (OP
[1])) & 0xFF00)));
4499 trace_output_16 (tmp
);
4506 uint16 a
= (GPR (OP
[0])) & 0xff;
4507 uint16 tmp
, b
= (GPR (OP
[1])) & 0xFF;
4508 trace_input ("lshb", OP_REG
, OP_REG
, OP_VOID
);
4509 if (a
& ((long)1 << 3))
4514 a
= (unsigned int) (a
& 0x7);
4516 /* A positive count specifies a shift to the left;
4517 * A negative count specifies a shift to the right. */
4523 sign_flag
= 0; /* Reset sign_flag. */
4524 SET_GPR (OP
[1], ((tmp
& 0xFF) | ((GPR (OP
[1])) & 0xFF00)));
4525 trace_output_16 (tmp
);
4532 uint16 tmp
, b
= GPR (OP
[1]);
4533 int16 a
= GPR (OP
[0]);
4534 trace_input ("lshw", OP_REG
, OP_REG
, OP_VOID
);
4535 if (a
& ((long)1 << 4))
4540 a
= (unsigned int) (a
& 0xf);
4542 /* A positive count specifies a shift to the left;
4543 * A negative count specifies a shift to the right. */
4549 sign_flag
= 0; /* Reset sign_flag. */
4550 SET_GPR (OP
[1], (tmp
& 0xffff));
4551 trace_output_16 (tmp
);
4558 uint16 tmp
, b
= GPR (OP
[1]);
4560 trace_input ("lshw", OP_CONSTANT5
, OP_REG
, OP_VOID
);
4561 /* A positive count specifies a shift to the left;
4562 * A negative count specifies a shift to the right. */
4568 sign_flag
= 0; /* Reset sign_flag. */
4569 SET_GPR (OP
[1], (tmp
& 0xffff));
4570 trace_output_16 (tmp
);
4577 uint32 tmp
, b
= GPR32 (OP
[1]);
4579 trace_input ("lshd", OP_CONSTANT6
, OP_REGP
, OP_VOID
);
4580 /* A positive count specifies a shift to the left;
4581 * A negative count specifies a shift to the right. */
4587 sign_flag
= 0; /* Reset sign flag. */
4589 SET_GPR32 (OP
[1], tmp
);
4590 trace_output_32 (tmp
);
4597 uint32 tmp
, b
= GPR32 (OP
[1]);
4598 uint16 a
= GPR (OP
[0]);
4599 trace_input ("lshd", OP_REG
, OP_REGP
, OP_VOID
);
4600 if (a
& ((long)1 << 5))
4605 a
= (unsigned int) (a
& 0x1f);
4606 /* A positive count specifies a shift to the left;
4607 * A negative count specifies a shift to the right. */
4613 sign_flag
= 0; /* Reset sign flag. */
4615 SET_GPR32 (OP
[1], tmp
);
4616 trace_output_32 (tmp
);
4624 int8 tmp
, b
= (GPR (OP
[1])) & 0xFF;
4625 trace_input ("ashub", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4626 /* A positive count specifies a shift to the left;
4627 * A negative count specifies a shift to the right. */
4633 sign_flag
= 0; /* Reset sign flag. */
4635 SET_GPR (OP
[1], ((tmp
& 0xFF) | ((GPR (OP
[1])) & 0xff00)));
4636 trace_output_16 (tmp
);
4644 int8 tmp
, b
= (GPR (OP
[1])) & 0xFF;
4645 trace_input ("ashub", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4646 /* A positive count specifies a shift to the left;
4647 * A negative count specifies a shift to the right. */
4653 sign_flag
= 0; /* Reset sign flag. */
4655 SET_GPR (OP
[1], ((tmp
& 0xFF) | ((GPR (OP
[1])) & 0xFF00)));
4656 trace_output_16 (tmp
);
4664 int16 a
= (GPR (OP
[0]));
4665 int8 tmp
, b
= (GPR (OP
[1])) & 0xFF;
4666 trace_input ("ashub", OP_REG
, OP_REG
, OP_VOID
);
4668 if (a
& ((long)1 << 3))
4673 a
= (unsigned int) (a
& 0x7);
4675 /* A positive count specifies a shift to the left;
4676 * A negative count specifies a shift to the right. */
4682 sign_flag
= 0; /* Reset sign flag. */
4684 SET_GPR (OP
[1], ((tmp
& 0xFF) | ((GPR (OP
[1])) & 0xFF00)));
4685 trace_output_16 (tmp
);
4693 int16 tmp
, b
= GPR (OP
[1]);
4695 trace_input ("ashuw", OP_CONSTANT5
, OP_REG
, OP_VOID
);
4696 /* A positive count specifies a shift to the left;
4697 * A negative count specifies a shift to the right. */
4703 sign_flag
= 0; /* Reset sign flag. */
4705 SET_GPR (OP
[1], (tmp
& 0xffff));
4706 trace_output_16 (tmp
);
4713 int16 tmp
, b
= GPR (OP
[1]);
4715 trace_input ("ashuw", OP_CONSTANT5
, OP_REG
, OP_VOID
);
4716 /* A positive count specifies a shift to the left;
4717 * A negative count specifies a shift to the right. */
4723 sign_flag
= 0; /* Reset sign flag. */
4724 SET_GPR (OP
[1], (tmp
& 0xffff));
4725 trace_output_16 (tmp
);
4733 int16 a
= GPR (OP
[0]), b
= GPR (OP
[1]);
4734 trace_input ("ashuw", OP_REG
, OP_REG
, OP_VOID
);
4736 if (a
& ((long)1 << 4))
4741 a
= (unsigned int) (a
& 0xf);
4742 /* A positive count specifies a shift to the left;
4743 * A negative count specifies a shift to the right. */
4750 sign_flag
= 0; /* Reset sign flag. */
4751 SET_GPR (OP
[1], (tmp
& 0xffff));
4752 trace_output_16 (tmp
);
4759 int32 tmp
,b
= GPR32 (OP
[1]);
4761 trace_input ("ashud", OP_CONSTANT6
, OP_REGP
, OP_VOID
);
4762 /* A positive count specifies a shift to the left;
4763 * A negative count specifies a shift to the right. */
4769 sign_flag
= 0; /* Reset sign flag. */
4770 SET_GPR32 (OP
[1], tmp
);
4771 trace_output_32 (tmp
);
4779 int32 a
= OP
[0], b
= GPR32 (OP
[1]);
4780 trace_input ("ashud", OP_CONSTANT6
, OP_REGP
, OP_VOID
);
4781 /* A positive count specifies a shift to the left;
4782 * A negative count specifies a shift to the right. */
4788 sign_flag
= 0; /* Reset sign flag. */
4789 SET_GPR32 (OP
[1], tmp
);
4790 trace_output_32 (tmp
);
4798 int32 a
= GPR32 (OP
[0]), b
= GPR32 (OP
[1]);
4799 trace_input ("ashud", OP_REGP
, OP_REGP
, OP_VOID
);
4801 if (a
& ((long)1 << 5))
4806 a
= (unsigned int) (a
& 0x1f);
4807 /* A positive count specifies a shift to the left;
4808 * A negative count specifies a shift to the right. */
4814 sign_flag
= 0; /* Reset sign flag. */
4815 SET_GPR32 (OP
[1], tmp
);
4816 trace_output_32 (tmp
);
4824 uint32 addr
= GPR (1);
4825 uint16 count
= OP
[0], reg
= 2;
4826 trace_input ("storm", OP_CONSTANT4
, OP_VOID
, OP_VOID
);
4829 State
.exception
= SIG_CR16_BUS
;
4830 State
.pc_changed
= 1; /* Don't increment the PC. */
4831 trace_output_void ();
4837 SW (addr
, (GPR (reg
)));
4841 if (reg
== 6) reg
= 8;
4846 trace_output_void ();
4854 uint32 addr
= GPR32 (6);
4855 uint16 count
= OP
[0], reg
= 2;
4856 trace_input ("stormp", OP_CONSTANT4
, OP_VOID
, OP_VOID
);
4859 State
.exception
= SIG_CR16_BUS
;
4860 State
.pc_changed
= 1; /* Don't increment the PC. */
4861 trace_output_void ();
4867 SW (addr
, (GPR (reg
)));
4871 if (reg
== 6) reg
= 8;
4874 SET_GPR32 (6, addr
);
4875 trace_output_void ();
4883 uint8 b
= (GPR (OP
[1])) & 0xff;
4884 uint16 tmp
= (~a
+ 1 + b
) & 0xff;
4885 trace_input ("subb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4886 /* see ../common/sim-alu.h for a more extensive discussion on how to
4887 compute the carry/overflow bits. */
4888 SET_PSR_C (tmp
> 0xff);
4889 SET_PSR_F (((a
& 0x80) != (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
4890 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
4891 trace_output_16 (tmp
);
4898 uint8 a
= OP
[0] & 0xFF;
4899 uint8 b
= (GPR (OP
[1])) & 0xFF;
4900 uint16 tmp
= (~a
+ 1 + b
) & 0xFF;
4901 trace_input ("subb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
4902 /* see ../common/sim-alu.h for a more extensive discussion on how to
4903 compute the carry/overflow bits. */
4904 SET_PSR_C (tmp
> 0xff);
4905 SET_PSR_F (((a
& 0x80) != (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
4906 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
4907 trace_output_16 (tmp
);
4914 uint8 a
= (GPR (OP
[0])) & 0xFF;
4915 uint8 b
= (GPR (OP
[1])) & 0xFF;
4916 uint16 tmp
= (~a
+ 1 + b
) & 0xff;
4917 trace_input ("subb", OP_REG
, OP_REG
, OP_VOID
);
4918 /* see ../common/sim-alu.h for a more extensive discussion on how to
4919 compute the carry/overflow bits. */
4920 SET_PSR_C (tmp
> 0xff);
4921 SET_PSR_F (((a
& 0x80) != (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
4922 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
4923 trace_output_16 (tmp
);
4931 uint16 b
= GPR (OP
[1]);
4932 uint16 tmp
= (~a
+ 1 + b
);
4933 trace_input ("subw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4934 /* see ../common/sim-alu.h for a more extensive discussion on how to
4935 compute the carry/overflow bits. */
4936 SET_PSR_C (tmp
> 0xffff);
4937 SET_PSR_F (((a
& 0x8000) != (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
4938 SET_GPR (OP
[1], tmp
);
4939 trace_output_16 (tmp
);
4947 uint16 b
= GPR (OP
[1]);
4948 uint32 tmp
= (~a
+ 1 + b
);
4949 trace_input ("subw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
4950 /* see ../common/sim-alu.h for a more extensive discussion on how to
4951 compute the carry/overflow bits. */
4952 SET_PSR_C (tmp
> 0xffff);
4953 SET_PSR_F (((a
& 0x8000) != (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
4954 SET_GPR (OP
[1], tmp
& 0xffff);
4955 trace_output_16 (tmp
);
4962 uint16 a
= GPR (OP
[0]);
4963 uint16 b
= GPR (OP
[1]);
4964 uint32 tmp
= (~a
+ 1 + b
);
4965 trace_input ("subw", OP_REG
, OP_REG
, OP_VOID
);
4966 /* see ../common/sim-alu.h for a more extensive discussion on how to
4967 compute the carry/overflow bits. */
4968 SET_PSR_C (tmp
> 0xffff);
4969 SET_PSR_F (((a
& 0x8000) != (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
4970 SET_GPR (OP
[1], tmp
& 0xffff);
4971 trace_output_16 (tmp
);
4979 uint8 b
= (GPR (OP
[1])) & 0xff;
4980 //uint16 tmp1 = a + 1;
4981 uint16 tmp1
= a
+ (PSR_C
);
4982 uint16 tmp
= (~tmp1
+ 1 + b
);
4983 trace_input ("subcb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
4984 /* see ../common/sim-alu.h for a more extensive discussion on how to
4985 compute the carry/overflow bits. */
4986 SET_PSR_C (tmp
> 0xff);
4987 SET_PSR_F (((a
& 0x80) != (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
4988 SET_GPR (OP
[1], tmp
);
4989 trace_output_16 (tmp
);
4997 uint16 b
= (GPR (OP
[1])) & 0xff;
4998 //uint16 tmp1 = a + 1;
4999 uint16 tmp1
= a
+ (PSR_C
);
5000 uint16 tmp
= (~tmp1
+ 1 + b
);
5001 trace_input ("subcb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
5002 /* see ../common/sim-alu.h for a more extensive discussion on how to
5003 compute the carry/overflow bits. */
5004 SET_PSR_C (tmp
> 0xff);
5005 SET_PSR_F (((a
& 0x80) != (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
5006 SET_GPR (OP
[1], tmp
);
5007 trace_output_16 (tmp
);
5014 uint16 a
= (GPR (OP
[0])) & 0xff;
5015 uint16 b
= (GPR (OP
[1])) & 0xff;
5016 uint16 tmp1
= a
+ (PSR_C
);
5017 uint16 tmp
= (~tmp1
+ 1 + b
);
5018 trace_input ("subcb", OP_REG
, OP_REG
, OP_VOID
);
5019 /* see ../common/sim-alu.h for a more extensive discussion on how to
5020 compute the carry/overflow bits. */
5021 SET_PSR_C (tmp
> 0xff);
5022 SET_PSR_F (((a
& 0x80) != (b
& 0x80)) && ((b
& 0x80) != (tmp
& 0x80)));
5023 SET_GPR (OP
[1], tmp
);
5024 trace_output_16 (tmp
);
5031 uint16 a
= OP
[0], b
= (GPR (OP
[1]));
5032 uint16 tmp1
= a
+ (PSR_C
);
5033 uint16 tmp
= (~tmp1
+ 1 + b
);
5034 trace_input ("subcw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
5035 /* see ../common/sim-alu.h for a more extensive discussion on how to
5036 compute the carry/overflow bits. */
5037 SET_PSR_C (tmp
> 0xffff);
5038 SET_PSR_F (((a
& 0x8000) != (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
5039 SET_GPR (OP
[1], tmp
);
5040 trace_output_16 (tmp
);
5048 uint16 b
= GPR (OP
[1]);
5049 uint16 tmp1
= a
+ (PSR_C
);
5050 uint16 tmp
= (~tmp1
+ 1 + b
);
5051 trace_input ("subcw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
5052 /* see ../common/sim-alu.h for a more extensive discussion on how to
5053 compute the carry/overflow bits. */
5054 SET_PSR_C (tmp
> 0xffff);
5055 SET_PSR_F (((a
& 0x8000) != (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
5056 SET_GPR (OP
[1], tmp
);
5057 trace_output_16 (tmp
);
5064 uint16 a
= (GPR (OP
[0])), b
= (GPR (OP
[1]));
5065 uint16 tmp1
= a
+ (PSR_C
);
5066 uint16 tmp
= (~tmp1
+ 1 + b
);
5067 trace_input ("subcw", OP_REG
, OP_REG
, OP_VOID
);
5068 /* see ../common/sim-alu.h for a more extensive discussion on how to
5069 compute the carry/overflow bits. */
5070 SET_PSR_C (tmp
> 0xffff);
5071 SET_PSR_F (((a
& 0x8000) != (b
& 0x8000)) && ((b
& 0x8000) != (tmp
& 0x8000)));
5072 SET_GPR (OP
[1], tmp
);
5073 trace_output_16 (tmp
);
5081 uint32 b
= GPR32 (OP
[1]);
5082 uint32 tmp
= (~a
+ 1 + b
);
5083 trace_input ("subd", OP_CONSTANT32
, OP_REGP
, OP_VOID
);
5084 /* see ../common/sim-alu.h for a more extensive discussion on how to
5085 compute the carry/overflow bits. */
5086 SET_PSR_C (tmp
> 0xffffffff);
5087 SET_PSR_F (((a
& 0x80000000) != (b
& 0x80000000)) &&
5088 ((b
& 0x80000000) != (tmp
& 0x80000000)));
5089 SET_GPR32 (OP
[1], tmp
);
5090 trace_output_32 (tmp
);
5097 uint32 a
= GPR32 (OP
[0]);
5098 uint32 b
= GPR32 (OP
[1]);
5099 uint32 tmp
= (~a
+ 1 + b
);
5100 trace_input ("subd", OP_REGP
, OP_REGP
, OP_VOID
);
5101 /* see ../common/sim-alu.h for a more extensive discussion on how to
5102 compute the carry/overflow bits. */
5103 SET_PSR_C (tmp
> 0xffffffff);
5104 SET_PSR_F (((a
& 0x80000000) != (b
& 0x80000000)) &&
5105 ((b
& 0x80000000) != (tmp
& 0x80000000)));
5106 SET_GPR32 (OP
[1], tmp
);
5107 trace_output_32 (tmp
);
5114 trace_input ("excp", OP_CONSTANT4
, OP_VOID
, OP_VOID
);
5118 #if (DEBUG & DEBUG_TRAP) == 0
5121 uint16 vec
= OP
[0] + TRAP_VECTOR_START
;
5124 SET_PSR (PSR
& PSR_SM_BIT
);
5129 #else /* if debugging use trap to print registers */
5132 static int first_time
= 1;
5137 (*cr16_callback
->printf_filtered
) (cr16_callback
, "Trap # PC ");
5138 for (i
= 0; i
< 16; i
++)
5139 (*cr16_callback
->printf_filtered
) (cr16_callback
, " %sr%d", (i
> 9) ? "" : " ", i
);
5140 (*cr16_callback
->printf_filtered
) (cr16_callback
, " a0 a1 f0 f1 c\n");
5143 (*cr16_callback
->printf_filtered
) (cr16_callback
, "Trap %2d 0x%.4x:", (int)OP
[0], (int)PC
);
5145 for (i
= 0; i
< 16; i
++)
5146 (*cr16_callback
->printf_filtered
) (cr16_callback
, " %.4x", (int) GPR (i
));
5148 for (i
= 0; i
< 2; i
++)
5149 (*cr16_callback
->printf_filtered
) (cr16_callback
, " %.2x%.8lx",
5150 ((int)(ACC (i
) >> 32) & 0xff),
5151 ((unsigned long) ACC (i
)) & 0xffffffff);
5153 (*cr16_callback
->printf_filtered
) (cr16_callback
, " %d %d %d\n",
5154 PSR_F
!= 0, PSR_F
!= 0, PSR_C
!= 0);
5155 (*cr16_callback
->flush_stdout
) (cr16_callback
);
5159 case 8: /* new system call trap */
5160 /* Trap 8 is used for simulating low-level I/O */
5162 unsigned32 result
= 0;
5165 /* Registers passed to trap 0. */
5167 #define FUNC GPR (0) /* function number. */
5168 #define PARM1 GPR (2) /* optional parm 1. */
5169 #define PARM2 GPR (3) /* optional parm 2. */
5170 #define PARM3 GPR (4) /* optional parm 3. */
5171 #define PARM4 GPR (5) /* optional parm 4. */
5173 /* Registers set by trap 0 */
5175 #define RETVAL(X) do { result = (0xffff & (X));SET_GPR (0, result);} while (0)
5176 #define RETVAL32(X) do { result = (X); SET_GPR32 (0, result);} while (0)
5177 #define RETERR(X) SET_GPR (4, (X)) /* return error code. */
5179 /* Turn a pointer in a register into a pointer into real memory. */
5181 #define MEMPTR(x) ((char *)(dmem_addr(x)))
5185 #if !defined(__GO32__) && !defined(_WIN32)
5186 case TARGET_SYS_fork
:
5187 trace_input ("<fork>", OP_VOID
, OP_VOID
, OP_VOID
);
5189 trace_output_16 (result
);
5193 case TARGET_SYS_getpid
:
5194 trace_input ("<getpid>", OP_VOID
, OP_VOID
, OP_VOID
);
5196 trace_output_16 (result
);
5199 case TARGET_SYS_kill
:
5200 trace_input ("<kill>", OP_REG
, OP_REG
, OP_VOID
);
5201 if (PARM1
== getpid ())
5203 trace_output_void ();
5204 State
.exception
= PARM2
;
5212 case 1: os_sig
= SIGHUP
; break;
5215 case 2: os_sig
= SIGINT
; break;
5218 case 3: os_sig
= SIGQUIT
; break;
5221 case 4: os_sig
= SIGILL
; break;
5224 case 5: os_sig
= SIGTRAP
; break;
5227 case 6: os_sig
= SIGABRT
; break;
5228 #elif defined(SIGIOT)
5229 case 6: os_sig
= SIGIOT
; break;
5232 case 7: os_sig
= SIGEMT
; break;
5235 case 8: os_sig
= SIGFPE
; break;
5238 case 9: os_sig
= SIGKILL
; break;
5241 case 10: os_sig
= SIGBUS
; break;
5244 case 11: os_sig
= SIGSEGV
; break;
5247 case 12: os_sig
= SIGSYS
; break;
5250 case 13: os_sig
= SIGPIPE
; break;
5253 case 14: os_sig
= SIGALRM
; break;
5256 case 15: os_sig
= SIGTERM
; break;
5259 case 16: os_sig
= SIGURG
; break;
5262 case 17: os_sig
= SIGSTOP
; break;
5265 case 18: os_sig
= SIGTSTP
; break;
5268 case 19: os_sig
= SIGCONT
; break;
5271 case 20: os_sig
= SIGCHLD
; break;
5272 #elif defined(SIGCLD)
5273 case 20: os_sig
= SIGCLD
; break;
5276 case 21: os_sig
= SIGTTIN
; break;
5279 case 22: os_sig
= SIGTTOU
; break;
5282 case 23: os_sig
= SIGIO
; break;
5283 #elif defined (SIGPOLL)
5284 case 23: os_sig
= SIGPOLL
; break;
5287 case 24: os_sig
= SIGXCPU
; break;
5290 case 25: os_sig
= SIGXFSZ
; break;
5293 case 26: os_sig
= SIGVTALRM
; break;
5296 case 27: os_sig
= SIGPROF
; break;
5299 case 28: os_sig
= SIGWINCH
; break;
5302 case 29: os_sig
= SIGLOST
; break;
5305 case 30: os_sig
= SIGUSR1
; break;
5308 case 31: os_sig
= SIGUSR2
; break;
5314 trace_output_void ();
5315 (*cr16_callback
->printf_filtered
) (cr16_callback
, "Unknown signal %d\n", PARM2
);
5316 (*cr16_callback
->flush_stdout
) (cr16_callback
);
5317 State
.exception
= SIGILL
;
5321 RETVAL (kill (PARM1
, PARM2
));
5322 trace_output_16 (result
);
5327 case TARGET_SYS_execve
:
5328 trace_input ("<execve>", OP_VOID
, OP_VOID
, OP_VOID
);
5329 RETVAL (execve (MEMPTR (PARM1
), (char **) MEMPTR (PARM2
<<16|PARM3
),
5330 (char **)MEMPTR (PARM4
)));
5331 trace_output_16 (result
);
5334 #ifdef TARGET_SYS_execv
5335 case TARGET_SYS_execv
:
5336 trace_input ("<execv>", OP_VOID
, OP_VOID
, OP_VOID
);
5337 RETVAL (execve (MEMPTR (PARM1
), (char **) MEMPTR (PARM2
), NULL
));
5338 trace_output_16 (result
);
5342 case TARGET_SYS_pipe
:
5347 trace_input ("<pipe>", OP_VOID
, OP_VOID
, OP_VOID
);
5349 RETVAL (pipe (host_fd
));
5350 SW (buf
, host_fd
[0]);
5351 buf
+= sizeof(uint16
);
5352 SW (buf
, host_fd
[1]);
5353 trace_output_16 (result
);
5357 #ifdef TARGET_SYS_wait
5358 case TARGET_SYS_wait
:
5361 trace_input ("<wait>", OP_REG
, OP_VOID
, OP_VOID
);
5362 RETVAL (wait (&status
));
5365 trace_output_16 (result
);
5370 case TARGET_SYS_getpid
:
5371 trace_input ("<getpid>", OP_VOID
, OP_VOID
, OP_VOID
);
5373 trace_output_16 (result
);
5376 case TARGET_SYS_kill
:
5377 trace_input ("<kill>", OP_REG
, OP_REG
, OP_VOID
);
5378 trace_output_void ();
5379 State
.exception
= PARM2
;
5383 case TARGET_SYS_read
:
5384 trace_input ("<read>", OP_REG
, OP_MEMREF
, OP_REG
);
5385 RETVAL (cr16_callback
->read (cr16_callback
, PARM1
,
5386 MEMPTR (((unsigned long)PARM3
<< 16)
5387 |((unsigned long)PARM2
)), PARM4
));
5388 trace_output_16 (result
);
5391 case TARGET_SYS_write
:
5392 trace_input ("<write>", OP_REG
, OP_MEMREF
, OP_REG
);
5393 RETVAL ((int)cr16_callback
->write (cr16_callback
, PARM1
,
5394 MEMPTR (((unsigned long)PARM3
<< 16) | PARM2
), PARM4
));
5395 trace_output_16 (result
);
5398 case TARGET_SYS_lseek
:
5399 trace_input ("<lseek>", OP_REG
, OP_REGP
, OP_REG
);
5400 RETVAL32 (cr16_callback
->lseek (cr16_callback
, PARM1
,
5401 ((((long) PARM3
) << 16) | PARM2
),
5403 trace_output_32 (result
);
5406 case TARGET_SYS_close
:
5407 trace_input ("<close>", OP_REG
, OP_VOID
, OP_VOID
);
5408 RETVAL (cr16_callback
->close (cr16_callback
, PARM1
));
5409 trace_output_16 (result
);
5412 case TARGET_SYS_open
:
5413 trace_input ("<open>", OP_MEMREF
, OP_REG
, OP_VOID
);
5414 RETVAL32 (cr16_callback
->open (cr16_callback
,
5415 MEMPTR ((((unsigned long)PARM2
)<<16)|PARM1
),
5417 trace_output_32 (result
);
5420 case TARGET_SYS_rename
:
5421 trace_input ("<rename>", OP_MEMREF
, OP_MEMREF
, OP_VOID
);
5422 RETVAL (cr16_callback
->rename (cr16_callback
,
5423 MEMPTR ((((unsigned long)PARM2
)<<16) |PARM1
),
5424 MEMPTR ((((unsigned long)PARM4
)<<16) |PARM3
)));
5425 trace_output_16 (result
);
5428 case 0x408: /* REVISIT: Added a dummy getenv call. */
5429 trace_input ("<getenv>", OP_MEMREF
, OP_MEMREF
, OP_VOID
);
5431 trace_output_32 (result
);
5434 case TARGET_SYS_exit
:
5435 trace_input ("<exit>", OP_VOID
, OP_VOID
, OP_VOID
);
5436 State
.exception
= SIG_CR16_EXIT
;
5437 trace_output_void ();
5440 case TARGET_SYS_unlink
:
5441 trace_input ("<unlink>", OP_MEMREF
, OP_VOID
, OP_VOID
);
5442 RETVAL (cr16_callback
->unlink (cr16_callback
,
5443 MEMPTR (((unsigned long)PARM2
<<16)|PARM1
)));
5444 trace_output_16 (result
);
5448 #ifdef TARGET_SYS_stat
5449 case TARGET_SYS_stat
:
5450 trace_input ("<stat>", OP_VOID
, OP_VOID
, OP_VOID
);
5451 /* stat system call. */
5453 struct stat host_stat
;
5456 RETVAL (stat (MEMPTR ((((unsigned long)PARM2
) << 16)|PARM1
), &host_stat
));
5460 /* The hard-coded offsets and sizes were determined by using
5461 * the CR16 compiler on a test program that used struct stat.
5463 SW (buf
, host_stat
.st_dev
);
5464 SW (buf
+2, host_stat
.st_ino
);
5465 SW (buf
+4, host_stat
.st_mode
);
5466 SW (buf
+6, host_stat
.st_nlink
);
5467 SW (buf
+8, host_stat
.st_uid
);
5468 SW (buf
+10, host_stat
.st_gid
);
5469 SW (buf
+12, host_stat
.st_rdev
);
5470 SLW (buf
+16, host_stat
.st_size
);
5471 SLW (buf
+20, host_stat
.st_atime
);
5472 SLW (buf
+28, host_stat
.st_mtime
);
5473 SLW (buf
+36, host_stat
.st_ctime
);
5475 trace_output_16 (result
);
5479 case TARGET_SYS_chown
:
5480 trace_input ("<chown>", OP_VOID
, OP_VOID
, OP_VOID
);
5481 RETVAL (chown (MEMPTR (PARM1
), PARM2
, PARM3
));
5482 trace_output_16 (result
);
5485 case TARGET_SYS_chmod
:
5486 trace_input ("<chmod>", OP_VOID
, OP_VOID
, OP_VOID
);
5487 RETVAL (chmod (MEMPTR (PARM1
), PARM2
));
5488 trace_output_16 (result
);
5491 #ifdef TARGET_SYS_utime
5492 case TARGET_SYS_utime
:
5493 trace_input ("<utime>", OP_REG
, OP_REG
, OP_REG
);
5494 /* Cast the second argument to void *, to avoid type mismatch
5495 if a prototype is present. */
5496 RETVAL (utime (MEMPTR (PARM1
), (void *) MEMPTR (PARM2
)));
5497 trace_output_16 (result
);
5501 #ifdef TARGET_SYS_time
5502 case TARGET_SYS_time
:
5503 trace_input ("<time>", OP_VOID
, OP_VOID
, OP_REG
);
5504 RETVAL32 (time (NULL
));
5505 trace_output_32 (result
);
5510 cr16_callback
->error (cr16_callback
, "Unknown syscall %d", FUNC
);
5513 if ((uint16
) result
== (uint16
) -1)
5514 RETERR (cr16_callback
->get_errno(cr16_callback
));
5527 uint16 a
= OP
[0] + 1, b
= OP
[1], c
= OP
[2], i
= 0;
5528 uint32 tmp
, sp_addr
= (GPR32 (15)) - (a
* 2) - 4, is_regp
= 0;
5529 trace_input ("push", OP_CONSTANT3
, OP_REG
, OP_REG
);
5535 SW (sp_addr
, (GPR (b
+i
)));
5541 tmp
= (GPR32 (b
+i
));
5543 tmp
= (GPR32 (b
+i
-1));
5562 /* Store RA address. */
5566 sp_addr
= (GPR32 (15)) - (a
* 2) - 4;
5567 SET_GPR32 (15, sp_addr
); /* Update SP address. */
5569 trace_output_void ();
5576 uint32 sp_addr
, tmp
, is_regp
= 0;
5577 uint16 a
= OP
[0] + 1, b
= OP
[1], c
= OP
[2], i
= 0;
5578 trace_input ("push", OP_CONSTANT3
, OP_REG
, OP_VOID
);
5581 sp_addr
= (GPR32 (15)) - (a
* 2) - 4;
5583 sp_addr
= (GPR32 (15)) - (a
* 2);
5589 SW (sp_addr
, (GPR (b
+i
)));
5595 tmp
= (GPR32 (b
+i
));
5597 tmp
= (GPR32 (b
+i
-1));
5616 /* Store RA address. */
5619 sp_addr
= (GPR32 (15)) - (a
* 2) - 4;
5622 sp_addr
= (GPR32 (15)) - (a
* 2);
5624 SET_GPR32 (15, sp_addr
); /* Update SP address. */
5626 trace_output_void ();
5634 uint32 sp_addr
= (GPR32 (15)), tmp
;
5635 trace_input ("push", OP_VOID
, OP_VOID
, OP_VOID
);
5637 SLW(sp_addr
-4,tmp
); /* Store RA address. */
5638 SET_GPR32 (15, (sp_addr
- 4)); /* Update SP address. */
5639 trace_output_void ();
5647 uint16 a
= OP
[0] + 1, b
= OP
[1], c
= OP
[2], i
= 0;
5648 uint32 tmp
, sp_addr
= (GPR32 (15)), is_regp
= 0;;
5649 trace_input ("pop", OP_CONSTANT3
, OP_REG
, OP_REG
);
5655 SET_GPR ((b
+i
), RW(sp_addr
));
5671 tmp
= (tmp
<< 16) | (GPR32 (b
+i
));
5673 tmp
= (tmp
<< 16) | (GPR32 (b
+i
-1));
5677 SET_GPR32 ((b
+i
), (((tmp
& 0xffff) << 16)
5678 | ((tmp
>> 16) & 0xffff)));
5680 SET_GPR32 ((b
+i
-1), (((tmp
& 0xffff) << 16)
5681 | ((tmp
>> 16) & 0xffff)));
5688 tmp
= RLW(sp_addr
); /* store RA also. */
5689 SET_GPR32 (14, (((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff)));
5691 SET_GPR32 (15, (sp_addr
+ 4)); /* Update SP address. */
5693 trace_output_void ();
5700 uint16 a
= OP
[0] + 1, b
= OP
[1], c
= OP
[2], i
= 0;
5701 uint32 tmp
, sp_addr
= (GPR32 (15)), is_regp
= 0;
5702 trace_input ("pop", OP_CONSTANT3
, OP_REG
, OP_VOID
);
5708 SET_GPR ((b
+i
), RW(sp_addr
));
5724 tmp
= ((tmp
<< 16) & 0xffffffff) | (GPR32 (b
+i
));
5726 tmp
= ((tmp
<< 16) & 0xffffffff) | (GPR32 (b
+i
-1));
5730 SET_GPR32 ((b
+i
), (((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff)));
5732 SET_GPR32 ((b
+i
-1), (((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff)));
5740 tmp
= RLW(sp_addr
); /* Store RA Reg. */
5741 SET_GPR32 (14, (((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff)));
5745 SET_GPR32 (15, sp_addr
); /* Update SP address. */
5747 trace_output_void ();
5754 uint32 sp_addr
= GPR32 (15);
5756 trace_input ("pop", OP_VOID
, OP_VOID
, OP_VOID
);
5759 SET_GPR32 (14, (((tmp
& 0xffff) << 16)| ((tmp
>> 16) & 0xffff)));
5760 SET_GPR32 (15, (sp_addr
+4)); /* Update SP address. */
5762 trace_output_void ();
5769 uint16 a
= OP
[0], b
= OP
[1];
5770 trace_input ("popret", OP_CONSTANT3
, OP_REG
, OP_REG
);
5772 JMP(((GPR32(14)) << 1) & 0xffffff);
5774 trace_output_void ();
5781 uint16 a
= OP
[0], b
= OP
[1];
5782 trace_input ("popret", OP_CONSTANT3
, OP_REG
, OP_VOID
);
5784 JMP(((GPR32(14)) << 1) & 0xffffff);
5786 trace_output_void ();
5794 trace_input ("popret", OP_VOID
, OP_VOID
, OP_VOID
);
5796 tmp
= (((GPR32(14)) << 1) & 0xffffff);
5797 /* If the resulting PC value is less than 0x00_0000 or greater
5798 than 0xFF_FFFF, this instruction causes an IAD trap.*/
5800 if ((tmp
< 0x0) || (tmp
> 0xFFFFFF))
5802 State
.exception
= SIG_CR16_BUS
;
5803 State
.pc_changed
= 1; /* Don't increment the PC. */
5804 trace_output_void ();
5810 trace_output_32 (tmp
);
5818 trace_input ("cinv[i]", OP_VOID
, OP_VOID
, OP_VOID
);
5820 trace_output_void ();
5827 trace_input ("cinv[i,u]", OP_VOID
, OP_VOID
, OP_VOID
);
5829 trace_output_void ();
5836 trace_input ("cinv[d]", OP_VOID
, OP_VOID
, OP_VOID
);
5838 trace_output_void ();
5845 trace_input ("cinv[i,u]", OP_VOID
, OP_VOID
, OP_VOID
);
5847 trace_output_void ();
5854 trace_input ("cinv[d,i]", OP_VOID
, OP_VOID
, OP_VOID
);
5856 trace_output_void ();
5863 trace_input ("cinv[d,i,u]", OP_VOID
, OP_VOID
, OP_VOID
);
5865 trace_output_void ();
5872 trace_input ("retx", OP_VOID
, OP_VOID
, OP_VOID
);
5874 trace_output_void ();
5881 trace_input ("di", OP_VOID
, OP_VOID
, OP_VOID
);
5883 trace_output_void ();
5890 trace_input ("ei", OP_VOID
, OP_VOID
, OP_VOID
);
5892 trace_output_void ();
5899 trace_input ("wait", OP_VOID
, OP_VOID
, OP_VOID
);
5900 State
.exception
= SIGTRAP
;
5901 trace_output_void ();
5908 trace_input ("ewait", OP_VOID
, OP_VOID
, OP_VOID
);
5910 trace_output_void ();
5917 uint8 tmp
, a
= (OP
[0]) & 0xff, b
= (GPR (OP
[1])) & 0xff;
5918 trace_input ("xorb", OP_CONSTANT4
, OP_REG
, OP_VOID
);
5920 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
5921 trace_output_16 (tmp
);
5928 uint8 tmp
, a
= (OP
[0]) & 0xff, b
= (GPR (OP
[1])) & 0xff;
5929 trace_input ("xorb", OP_CONSTANT16
, OP_REG
, OP_VOID
);
5931 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
5932 trace_output_16 (tmp
);
5939 uint8 tmp
, a
= (GPR (OP
[0])) & 0xff, b
= (GPR (OP
[1])) & 0xff;
5940 trace_input ("xorb", OP_REG
, OP_REG
, OP_VOID
);
5942 SET_GPR (OP
[1], (tmp
| ((GPR (OP
[1])) & 0xff00)));
5943 trace_output_16 (tmp
);
5950 uint16 tmp
, a
= (OP
[0]), b
= (GPR (OP
[1]));
5951 trace_input ("xorw", OP_CONSTANT4
, OP_REG
, OP_VOID
);
5953 SET_GPR (OP
[1], tmp
);
5954 trace_output_16 (tmp
);
5961 uint16 tmp
, a
= (OP
[0]), b
= (GPR (OP
[1]));
5962 trace_input ("xorw", OP_CONSTANT16
, OP_REG
, OP_VOID
);
5964 SET_GPR (OP
[1], tmp
);
5965 trace_output_16 (tmp
);
5972 uint16 tmp
, a
= (GPR (OP
[0])), b
= (GPR (OP
[1]));
5973 trace_input ("xorw", OP_REG
, OP_REG
, OP_VOID
);
5975 SET_GPR (OP
[1], tmp
);
5976 trace_output_16 (tmp
);
5979 /*REVISIT FOR LPR/SPR . */
5985 uint16 a
= GPR (OP
[0]);
5986 trace_input ("lpr", OP_REG
, OP_REG
, OP_VOID
);
5987 SET_CREG (OP
[1], a
);
5988 trace_output_16 (a
);
5995 uint32 a
= GPR32 (OP
[0]);
5996 trace_input ("lprd", OP_REGP
, OP_REG
, OP_VOID
);
5997 SET_CREG (OP
[1], a
);
5998 trace_output_flag ();
6005 uint16 a
= CREG (OP
[0]);
6006 trace_input ("spr", OP_REG
, OP_REG
, OP_VOID
);
6008 trace_output_16 (a
);
6015 uint32 a
= CREG (OP
[0]);
6016 trace_input ("sprd", OP_REGP
, OP_REGP
, OP_VOID
);
6017 SET_GPR32 (OP
[1], a
);
6018 trace_output_32 (a
);
6025 trace_input ("null", OP_VOID
, OP_VOID
, OP_VOID
);
6026 State
.exception
= SIG_CR16_STOP
;