}
entry = seg->selector & ~0x7;
- if (limit == 0 || entry + 7 > limit)
+ if ((limit == 0) || ((UINT32)(entry + 7) > limit))
return 0;
v1 = READ32PL0(base + entry );
}
entry = gate->segment & ~0x7;
- if (limit == 0 || entry + 7 > limit)
+ if ((limit == 0) || ((UINT32)(entry + 7) > limit))
return;
v1 = READ32PL0(base + entry );
else
stack_limit = 6;
// TODO: Add check for error code (2 extra bytes)
- if(REG32(ESP) < stack_limit)
+ if((int)(REG32(ESP)) < stack_limit)
{
logerror("IRQ: Stack has no space left (needs %i bytes).\n",stack_limit);
FAULT_EXP(FAULT_SS,0)
}
if(operand32 != 0)
{
- if(newESP < ((gate.dword_count & 0x1f) + 16))
+ if(newESP < (UINT32)((gate.dword_count & 0x1f) + 16))
{
logerror("CALL: Call gate: New stack has no room for 32-bit return address and parameters.\n");
FAULT(FAULT_SS,0) // #SS(0)
}
else
{
- if(newESP < ((gate.dword_count & 0x1f) + 8))
+ if(newESP < (UINT32)((gate.dword_count & 0x1f) + 8))
{
logerror("CALL: Call gate: New stack has no room for 16-bit return address and parameters.\n");
FAULT(FAULT_SS,0) // #SS(0)
void I386_OPS_BASE::build_cycle_table()
{
- int i, j;
+ uint32_t i, j;
for (j=0; j < X86_NUM_CPUS; j++)
{
// cycle_table_rm[j] = (UINT8 *)malloc(CYCLES_NUM_OPCODES);
_cpustate->lock_table[1][i] = false;
}
- for (i=0; i < sizeof(x86_opcode_table)/sizeof(X86_OPCODE); i++)
+ for (i=0; i < (int)(sizeof(x86_opcode_table) / sizeof(X86_OPCODE)); i++)
{
const X86_OPCODE *op = &x86_opcode_table[i];
INLINE int floatx80_is_inf(floatx80 fx);
INLINE int floatx80_is_denormal(floatx80 fx);
INLINE floatx80 floatx80_abs(floatx80 fx);
+
+ INLINE UINT64 __SWAP64(UINT64 in);
INLINE double fx80_to_double(floatx80 fx);
INLINE floatx80 double_to_fx80(double in);
INLINE floatx80 READ80( UINT32 ea);
return fx;
}
+inline UINT64 I386_OPS_BASE::__SWAP64(UINT64 in)
+{
+ typedef union {
+ struct {
+ uint8_t h7, h6, h5, h4, h3, h2, h, l;
+ } b;
+ UINT64 ld;
+ } d1_t;
+
+ d1_t id, od;
+ id.ld = in;
+ od.b.h7 = id.b.l;
+ od.b.h6 = id.b.h;
+ od.b.h5 = id.b.h2;
+ od.b.h4 = id.b.h3;
+ od.b.h3 = id.b.h4;
+ od.b.h2 = id.b.h5;
+ od.b.h = id.b.h6;
+ od.b.l = id.b.h7;
+
+ return od.ld;
+}
+
INLINE double I386_OPS_BASE::fx80_to_double(floatx80 fx)
{
- UINT64 d = floatx80_to_float64(fx);
- return *(double*)&d;
+ union {
+ UINT64 ld;
+ double fd; // WIP: If sizeof(double) != sizeof(UINT64).(or IEEE 754 format has changed).
+ } d;
+ UINT64 nd;
+ nd = floatx80_to_float64(fx);
+#if __FLOAT_WORD_ORDER != __BYTE_ORDER
+ nd = __SWAP64(nd);
+#endif
+ d.ld = nd;
+ return d.fd;
}
INLINE floatx80 I386_OPS_BASE::double_to_fx80(double in)
{
- return float64_to_floatx80(*(UINT64*)&in);
+ union {
+ UINT64 ld;
+ double fd; // WIP: If sizeof(double) != sizeof(UINT64).(or IEEE 754 format has changed).
+ } d;
+ UINT64 nd;
+ d.fd = in;
+ nd = d.ld;
+#if __FLOAT_WORD_ORDER != __BYTE_ORDER
+ nd = __SWAP64(nd);
+#endif
+ return float64_to_floatx80(nd);
}
INLINE floatx80 I386_OPS_BASE::READ80( UINT32 ea)