Move flags and eflags variables into cpu_struct.
This commit is contained in:
parent
c1565eb42f
commit
a4d3aa1912
25 changed files with 1013 additions and 958 deletions
114
src/x86_flags.h
114
src/x86_flags.h
|
|
@ -66,7 +66,7 @@ static inline int ZF_SET()
|
|||
return !cpu_state.flags_res;
|
||||
|
||||
case FLAGS_UNKNOWN:
|
||||
return flags & Z_FLAG;
|
||||
return cpu_state.flags & Z_FLAG;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -106,7 +106,7 @@ static inline int NF_SET()
|
|||
return cpu_state.flags_res & 0x80000000;
|
||||
|
||||
case FLAGS_UNKNOWN:
|
||||
return flags & N_FLAG;
|
||||
return cpu_state.flags & N_FLAG;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -142,7 +142,7 @@ static inline int PF_SET()
|
|||
return znptable8[cpu_state.flags_res & 0xff] & P_FLAG;
|
||||
|
||||
case FLAGS_UNKNOWN:
|
||||
return flags & P_FLAG;
|
||||
return cpu_state.flags & P_FLAG;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ static inline int VF_SET()
|
|||
return ((cpu_state.flags_op2 == 1) && (cpu_state.flags_op1 & 0x80000000));
|
||||
|
||||
case FLAGS_UNKNOWN:
|
||||
return flags & V_FLAG;
|
||||
return cpu_state.flags & V_FLAG;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -234,7 +234,7 @@ static inline int AF_SET()
|
|||
return ((cpu_state.flags_op1 & 0xF) - (cpu_state.flags_op2 & 0xF)) & 0x10;
|
||||
|
||||
case FLAGS_UNKNOWN:
|
||||
return flags & A_FLAG;
|
||||
return cpu_state.flags & A_FLAG;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -286,7 +286,7 @@ static inline int CF_SET()
|
|||
case FLAGS_INC16:
|
||||
case FLAGS_INC32:
|
||||
case FLAGS_UNKNOWN:
|
||||
return flags & C_FLAG;
|
||||
return cpu_state.flags & C_FLAG;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -309,7 +309,7 @@ static inline void flags_rebuild()
|
|||
if (ZF_SET()) tempf |= Z_FLAG;
|
||||
if (NF_SET()) tempf |= N_FLAG;
|
||||
if (VF_SET()) tempf |= V_FLAG;
|
||||
flags = (flags & ~0x8d5) | tempf;
|
||||
cpu_state.flags = (cpu_state.flags & ~0x8d5) | tempf;
|
||||
cpu_state.flags_op = FLAGS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
|
@ -324,9 +324,9 @@ static inline void flags_rebuild_c()
|
|||
if (cpu_state.flags_op != FLAGS_UNKNOWN)
|
||||
{
|
||||
if (CF_SET())
|
||||
flags |= C_FLAG;
|
||||
cpu_state.flags |= C_FLAG;
|
||||
else
|
||||
flags &= ~C_FLAG;
|
||||
cpu_state.flags &= ~C_FLAG;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -447,67 +447,85 @@ static inline void setsub32nc(uint32_t a, uint32_t b)
|
|||
|
||||
static inline void setadc8(uint8_t a, uint8_t b)
|
||||
{
|
||||
uint16_t c=(uint16_t)a+(uint16_t)b+tempc;
|
||||
uint16_t c = (uint16_t)a + (uint16_t)b + tempc;
|
||||
cpu_state.flags_op = FLAGS_UNKNOWN;
|
||||
flags&=~0x8D5;
|
||||
flags|=znptable8[c&0xFF];
|
||||
if (c&0x100) flags|=C_FLAG;
|
||||
if (!((a^b)&0x80)&&((a^c)&0x80)) flags|=V_FLAG;
|
||||
if (((a&0xF)+(b&0xF))&0x10) flags|=A_FLAG;
|
||||
cpu_state.flags &= ~0x8D5;
|
||||
cpu_state.flags |= znptable8[c&0xFF];
|
||||
if (c & 0x100)
|
||||
cpu_state.flags |= C_FLAG;
|
||||
if (!((a ^ b) & 0x80) && ((a ^ c) & 0x80))
|
||||
cpu_state.flags |= V_FLAG;
|
||||
if (((a & 0xF) + (b & 0xF)) & 0x10)
|
||||
cpu_state.flags |= A_FLAG;
|
||||
}
|
||||
static inline void setadc16(uint16_t a, uint16_t b)
|
||||
{
|
||||
uint32_t c=(uint32_t)a+(uint32_t)b+tempc;
|
||||
uint32_t c = (uint32_t)a + (uint32_t)b + tempc;
|
||||
cpu_state.flags_op = FLAGS_UNKNOWN;
|
||||
flags&=~0x8D5;
|
||||
flags|=znptable16[c&0xFFFF];
|
||||
if (c&0x10000) flags|=C_FLAG;
|
||||
if (!((a^b)&0x8000)&&((a^c)&0x8000)) flags|=V_FLAG;
|
||||
if (((a&0xF)+(b&0xF))&0x10) flags|=A_FLAG;
|
||||
cpu_state.flags &= ~0x8D5;
|
||||
cpu_state.flags |= znptable16[c&0xFFFF];
|
||||
if (c & 0x10000)
|
||||
cpu_state.flags |= C_FLAG;
|
||||
if (!((a ^ b) & 0x8000) && ((a ^ c) & 0x8000))
|
||||
cpu_state.flags |= V_FLAG;
|
||||
if (((a & 0xF) + (b & 0xF)) & 0x10)
|
||||
cpu_state.flags |= A_FLAG;
|
||||
}
|
||||
|
||||
static inline void setsbc8(uint8_t a, uint8_t b)
|
||||
{
|
||||
uint16_t c=(uint16_t)a-(((uint16_t)b)+tempc);
|
||||
uint16_t c = (uint16_t)a - (((uint16_t)b) + tempc);
|
||||
cpu_state.flags_op = FLAGS_UNKNOWN;
|
||||
flags&=~0x8D5;
|
||||
flags|=znptable8[c&0xFF];
|
||||
if (c&0x100) flags|=C_FLAG;
|
||||
if ((a^b)&(a^c)&0x80) flags|=V_FLAG;
|
||||
if (((a&0xF)-(b&0xF))&0x10) flags|=A_FLAG;
|
||||
cpu_state.flags &= ~0x8D5;
|
||||
cpu_state.flags |= znptable8[c&0xFF];
|
||||
if (c & 0x100)
|
||||
cpu_state.flags |= C_FLAG;
|
||||
if ((a ^ b) & (a ^ c) & 0x80)
|
||||
cpu_state.flags |= V_FLAG;
|
||||
if (((a & 0xF) - (b & 0xF)) & 0x10)
|
||||
cpu_state.flags |= A_FLAG;
|
||||
}
|
||||
static inline void setsbc16(uint16_t a, uint16_t b)
|
||||
{
|
||||
uint32_t c=(uint32_t)a-(((uint32_t)b)+tempc);
|
||||
uint32_t c = (uint32_t)a - (((uint32_t)b) + tempc);
|
||||
cpu_state.flags_op = FLAGS_UNKNOWN;
|
||||
flags&=~0x8D5;
|
||||
flags|=(znptable16[c&0xFFFF]&~4);
|
||||
flags|=(znptable8[c&0xFF]&4);
|
||||
if (c&0x10000) flags|=C_FLAG;
|
||||
if ((a^b)&(a^c)&0x8000) flags|=V_FLAG;
|
||||
if (((a&0xF)-(b&0xF))&0x10) flags|=A_FLAG;
|
||||
cpu_state.flags &= ~0x8D5;
|
||||
cpu_state.flags |= (znptable16[c&0xFFFF] & ~4);
|
||||
cpu_state.flags |= (znptable8[c&0xFF] & 4);
|
||||
if (c & 0x10000)
|
||||
cpu_state.flags |= C_FLAG;
|
||||
if ((a ^ b) & (a ^ c) & 0x8000)
|
||||
cpu_state.flags |= V_FLAG;
|
||||
if (((a & 0xF) - (b & 0xF)) & 0x10)
|
||||
cpu_state.flags |= A_FLAG;
|
||||
}
|
||||
|
||||
static inline void setadc32(uint32_t a, uint32_t b)
|
||||
{
|
||||
uint32_t c=(uint32_t)a+(uint32_t)b+tempc;
|
||||
uint32_t c = (uint32_t)a + (uint32_t)b + tempc;
|
||||
cpu_state.flags_op = FLAGS_UNKNOWN;
|
||||
flags&=~0x8D5;
|
||||
flags|=((c&0x80000000)?N_FLAG:((!c)?Z_FLAG:0));
|
||||
flags|=(znptable8[c&0xFF]&P_FLAG);
|
||||
if ((c<a) || (c==a && tempc)) flags|=C_FLAG;
|
||||
if (!((a^b)&0x80000000)&&((a^c)&0x80000000)) flags|=V_FLAG;
|
||||
if (((a&0xF)+(b&0xF)+tempc)&0x10) flags|=A_FLAG;
|
||||
cpu_state.flags &= ~0x8D5;
|
||||
cpu_state.flags |= ((c & 0x80000000) ? N_FLAG : ((!c) ? Z_FLAG : 0));
|
||||
cpu_state.flags |= (znptable8[c&0xFF] & P_FLAG);
|
||||
if ((c < a) || (c == a && tempc))
|
||||
cpu_state.flags |= C_FLAG;
|
||||
if (!((a ^ b) & 0x80000000) && ((a ^ c) & 0x80000000))
|
||||
cpu_state.flags |= V_FLAG;
|
||||
if (((a & 0xF) + (b & 0xF) + tempc) & 0x10)
|
||||
cpu_state.flags |= A_FLAG;
|
||||
}
|
||||
static inline void setsbc32(uint32_t a, uint32_t b)
|
||||
{
|
||||
uint32_t c=(uint32_t)a-(((uint32_t)b)+tempc);
|
||||
uint32_t c = (uint32_t)a - (((uint32_t)b) + tempc);
|
||||
cpu_state.flags_op = FLAGS_UNKNOWN;
|
||||
flags&=~0x8D5;
|
||||
flags|=((c&0x80000000)?N_FLAG:((!c)?Z_FLAG:0));
|
||||
flags|=(znptable8[c&0xFF]&P_FLAG);
|
||||
if ((c>a) || (c==a && tempc)) flags|=C_FLAG;
|
||||
if ((a^b)&(a^c)&0x80000000) flags|=V_FLAG;
|
||||
if (((a&0xF)-((b&0xF)+tempc))&0x10) flags|=A_FLAG;
|
||||
cpu_state.flags &= ~0x8D5;
|
||||
cpu_state.flags |= ((c & 0x80000000) ? N_FLAG : ((!c) ? Z_FLAG : 0));
|
||||
cpu_state.flags |= (znptable8[c&0xFF] & P_FLAG);
|
||||
if ((c > a) || (c == a && tempc))
|
||||
cpu_state.flags |= C_FLAG;
|
||||
if ((a ^ b) & (a ^ c) & 0x80000000)
|
||||
cpu_state.flags |= V_FLAG;
|
||||
if (((a & 0xF) - ((b & 0xF) + tempc)) & 0x10)
|
||||
cpu_state.flags |= A_FLAG;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue