#include "config.h"
#include "exec.h"
+#ifndef CALL_FROM_TB0
+#define CALL_FROM_TB0(func) func();
+#endif
+#ifndef CALL_FROM_TB1
+#define CALL_FROM_TB1(func, arg0) func(arg0);
+#endif
+#ifndef CALL_FROM_TB1_CONST16
+#define CALL_FROM_TB1_CONST16(func, arg0) CALL_FROM_TB1(func, arg0);
+#endif
+#ifndef CALL_FROM_TB2
+#define CALL_FROM_TB2(func, arg0, arg1) func(arg0, arg1);
+#endif
+#ifndef CALL_FROM_TB2_CONST16
+#define CALL_FROM_TB2_CONST16(func, arg0, arg1) \
+CALL_FROM_TB2(func, arg0, arg1);
+#endif
+#ifndef CALL_FROM_TB3
+#define CALL_FROM_TB3(func, arg0, arg1, arg2) func(arg0, arg1, arg2);
+#endif
+#ifndef CALL_FROM_TB4
+#define CALL_FROM_TB4(func, arg0, arg1, arg2, arg3) \
+ func(arg0, arg1, arg2, arg3);
+#endif
+
#define REG 1
#include "op_template.c"
#undef REG
tmp = T0;
T0 += T1;
- if ((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31)) {
- CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);
+ if (((tmp ^ T1 ^ (-1)) & (T0 ^ T1)) >> 31) {
+ /* operands of same sign, result different sign */
+ CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);
}
RETURN();
}
tmp = T0;
T0 = (int32_t)T0 - (int32_t)T1;
- if (!((T0 >> 31) ^ (T1 >> 31) ^ (tmp >> 31))) {
- CALL_FROM_TB1(do_raise_exception, EXCP_OVERFLOW);
+ if (((tmp ^ T1) & (tmp ^ T0)) >> 31) {
+ /* operands of different sign, first operand and result different sign */
+ CALL_FROM_TB1(do_raise_exception_direct, EXCP_OVERFLOW);
}
RETURN();
}
void op_mult (void)
{
- set_HILO((int64_t)T0 * (int64_t)T1);
+ set_HILO((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
RETURN();
}
{
int64_t tmp;
- tmp = ((int64_t)T0 * (int64_t)T1);
+ tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
set_HILO((int64_t)get_HILO() + tmp);
RETURN();
}
{
int64_t tmp;
- tmp = ((int64_t)T0 * (int64_t)T1);
+ tmp = ((int64_t)(int32_t)T0 * (int64_t)(int32_t)T1);
set_HILO((int64_t)get_HILO() - tmp);
RETURN();
}
/* Branchs */
//#undef USE_DIRECT_JUMP
-#define EIP env->PC
+
+void OPPROTO op_goto_tb0(void)
+{
+ GOTO_TB(op_goto_tb0, PARAM1, 0);
+}
+
+void OPPROTO op_goto_tb1(void)
+{
+ GOTO_TB(op_goto_tb1, PARAM1, 1);
+}
/* Branch to register */
void op_save_breg_target (void)
RETURN();
}
-/* Unconditional branch */
-void op_branch (void)
-{
- JUMP_TB(branch, PARAM1, 0, PARAM2);
- RETURN();
-}
-
void op_save_btarget (void)
{
env->btarget = PARAM1;
RETURN();
}
-void op_bcond (void)
+void op_jnz_T2 (void)
{
- if (T2) {
- JUMP_TB(bcond, PARAM1, 0, PARAM2);
- } else {
- JUMP_TB(bcond, PARAM1, 1, PARAM3);
- }
- RETURN();
-}
-
-/* Likely branch (used to skip the delay slot) */
-void op_blikely (void)
-{
- /* If the test is false, skip the delay slot */
- if (T2 == 0) {
- env->hflags = PARAM3;
- JUMP_TB(blikely, PARAM1, 1, PARAM2);
- }
+ if (T2)
+ GOTO_LABEL_PARAM(1);
RETURN();
}
void op_trap (void)
{
if (T0) {
- CALL_FROM_TB1(do_raise_exception, EXCP_TRAP);
+ CALL_FROM_TB1(do_raise_exception_direct, EXCP_TRAP);
}
RETURN();
}
+void op_debug (void)
+{
+ CALL_FROM_TB1(do_raise_exception, EXCP_DEBUG);
+}
+
void op_set_lladdr (void)
{
env->CP0_LLAddr = T2;
EXIT_TB();
}
+void op_wait (void)
+{
+ env->halted = 1;
+ CALL_FROM_TB1(do_raise_exception, EXCP_HLT);
+}