#ifdef TARGET_X86_64
void OPPROTO op_bswapq_T0(void)
{
- T0 = bswap64(T0);
+ helper_bswapq_T0();
}
#endif
#endif
/* division, flags are undefined */
-/* XXX: add exceptions for overflow */
void OPPROTO op_divb_AL_T0(void)
{
if (den == 0) {
raise_exception(EXCP00_DIVZ);
}
- q = (num / den) & 0xff;
+ q = (num / den);
+ if (q > 0xff)
+ raise_exception(EXCP00_DIVZ);
+ q &= 0xff;
r = (num % den) & 0xff;
EAX = (EAX & ~0xffff) | (r << 8) | q;
}
if (den == 0) {
raise_exception(EXCP00_DIVZ);
}
- q = (num / den) & 0xff;
+ q = (num / den);
+ if (q != (int8_t)q)
+ raise_exception(EXCP00_DIVZ);
+ q &= 0xff;
r = (num % den) & 0xff;
EAX = (EAX & ~0xffff) | (r << 8) | q;
}
if (den == 0) {
raise_exception(EXCP00_DIVZ);
}
- q = (num / den) & 0xffff;
+ q = (num / den);
+ if (q > 0xffff)
+ raise_exception(EXCP00_DIVZ);
+ q &= 0xffff;
r = (num % den) & 0xffff;
EAX = (EAX & ~0xffff) | q;
EDX = (EDX & ~0xffff) | r;
if (den == 0) {
raise_exception(EXCP00_DIVZ);
}
- q = (num / den) & 0xffff;
+ q = (num / den);
+ if (q != (int16_t)q)
+ raise_exception(EXCP00_DIVZ);
+ q &= 0xffff;
r = (num % den) & 0xffff;
EAX = (EAX & ~0xffff) | q;
EDX = (EDX & ~0xffff) | r;
void OPPROTO op_hlt(void)
{
env->hflags &= ~HF_INHIBIT_IRQ_MASK; /* needed if sti is just before */
+ env->hflags |= HF_HALTED_MASK;
env->exception_index = EXCP_HLT;
cpu_loop_exit();
}
void op_addl_A0_SS(void)
{
- A0 += (long)env->segs[R_SS].base;
+ A0 = (uint32_t)(A0 + env->segs[R_SS].base);
}
void op_subl_A0_2(void)
}
#ifdef TARGET_X86_64
+void op_subq_A0_2(void)
+{
+ A0 -= 2;
+}
+
void op_subq_A0_8(void)
{
A0 -= 8;
helper_enter_level(PARAM1, PARAM2);
}
+#ifdef TARGET_X86_64
+void OPPROTO op_enter64_level(void)
+{
+ helper_enter64_level(PARAM1, PARAM2);
+}
+#endif
+
void OPPROTO op_sysenter(void)
{
helper_sysenter();
}
EAX = (EAX & ~0xffff) | al | (ah << 8);
CC_SRC = eflags;
+ FORCE_RET();
}
void OPPROTO op_aas(void)
}
EAX = (EAX & ~0xffff) | al | (ah << 8);
CC_SRC = eflags;
+ FORCE_RET();
}
void OPPROTO op_daa(void)
eflags |= parity_table[al]; /* pf */
eflags |= (al & 0x80); /* sf */
CC_SRC = eflags;
+ FORCE_RET();
}
void OPPROTO op_das(void)
eflags |= parity_table[al]; /* pf */
eflags |= (al & 0x80); /* sf */
CC_SRC = eflags;
+ FORCE_RET();
}
/* segment handling */
FORCE_RET();
}
+void OPPROTO op_fistt_ST0_A0(void)
+{
+#if defined(__sparc__) && !defined(__sparc_v9__)
+ register CPU86_LDouble d asm("o0");
+#else
+ CPU86_LDouble d;
+#endif
+ int val;
+
+ d = ST0;
+ val = floatx_to_int32_round_to_zero(d, &env->fp_status);
+ if (val != (int16_t)val)
+ val = -32768;
+ stw(A0, val);
+ FORCE_RET();
+}
+
+void OPPROTO op_fisttl_ST0_A0(void)
+{
+#if defined(__sparc__) && !defined(__sparc_v9__)
+ register CPU86_LDouble d asm("o0");
+#else
+ CPU86_LDouble d;
+#endif
+ int val;
+
+ d = ST0;
+ val = floatx_to_int32_round_to_zero(d, &env->fp_status);
+ stl(A0, val);
+ FORCE_RET();
+}
+
+void OPPROTO op_fisttll_ST0_A0(void)
+{
+#if defined(__sparc__) && !defined(__sparc_v9__)
+ register CPU86_LDouble d asm("o0");
+#else
+ CPU86_LDouble d;
+#endif
+ int64_t val;
+
+ d = ST0;
+ val = floatx_to_int64_round_to_zero(d, &env->fp_status);
+ stq(A0, val);
+ FORCE_RET();
+}
+
void OPPROTO op_fbld_ST0_A0(void)
{
helper_fbld_ST0_A0();
/* FPU operations */
+const int fcom_ccval[4] = {0x0100, 0x4000, 0x0000, 0x4500};
+
void OPPROTO op_fcom_ST0_FT0(void)
{
- int cc;
- switch(floatx_compare(ST0, FT0, &env->fp_status)) {
- case -1:
- cc = 0x0100;
- break;
- case 0:
- cc = 0x4000;
- break;
- case 1:
- cc = 0x0000;
- break;
- case 2:
- default:
- cc = 0x4500;
- break;
- }
- env->fpus = (env->fpus & ~0x4500) | cc;
+ int ret;
+
+ ret = floatx_compare(ST0, FT0, &env->fp_status);
+ env->fpus = (env->fpus & ~0x4500) | fcom_ccval[ret + 1];
FORCE_RET();
}
void OPPROTO op_fucom_ST0_FT0(void)
{
- int cc;
- switch(floatx_compare_quiet(ST0, FT0, &env->fp_status)) {
- case -1:
- cc = 0x0100;
- break;
- case 0:
- cc = 0x4000;
- break;
- case 1:
- cc = 0x0000;
- break;
- case 2:
- default:
- cc = 0x4500;
- break;
- }
- env->fpus = (env->fpus & ~0x4500) | cc;
+ int ret;
+
+ ret = floatx_compare_quiet(ST0, FT0, &env->fp_status);
+ env->fpus = (env->fpus & ~0x4500) | fcom_ccval[ret+ 1];
FORCE_RET();
}
+const int fcomi_ccval[4] = {CC_C, CC_Z, 0, CC_Z | CC_P | CC_C};
+
void OPPROTO op_fcomi_ST0_FT0(void)
{
- int eflags, cc;
- switch(floatx_compare(ST0, FT0, &env->fp_status)) {
- case -1:
- cc = CC_C;
- break;
- case 0:
- cc = CC_Z;
- break;
- case 1:
- cc = 0;
- break;
- case 2:
- default:
- cc = CC_Z | CC_P | CC_C;
- break;
- }
+ int eflags;
+ int ret;
+
+ ret = floatx_compare(ST0, FT0, &env->fp_status);
eflags = cc_table[CC_OP].compute_all();
- eflags = (eflags & ~(CC_Z | CC_P | CC_C)) | cc;
+ eflags = (eflags & ~(CC_Z | CC_P | CC_C)) | fcomi_ccval[ret + 1];
CC_SRC = eflags;
FORCE_RET();
}
void OPPROTO op_fucomi_ST0_FT0(void)
{
- int eflags, cc;
- switch(floatx_compare_quiet(ST0, FT0, &env->fp_status)) {
- case -1:
- cc = CC_C;
- break;
- case 0:
- cc = CC_Z;
- break;
- case 1:
- cc = 0;
- break;
- case 2:
- default:
- cc = CC_Z | CC_P | CC_C;
- break;
- }
+ int eflags;
+ int ret;
+
+ ret = floatx_compare_quiet(ST0, FT0, &env->fp_status);
eflags = cc_table[CC_OP].compute_all();
- eflags = (eflags & ~(CC_Z | CC_P | CC_C)) | cc;
+ eflags = (eflags & ~(CC_Z | CC_P | CC_C)) | fcomi_ccval[ret + 1];
CC_SRC = eflags;
FORCE_RET();
}