Merge pull request #1074 from lioncash/bool

dyncom: Minor changes to CondPassed
This commit is contained in:
bunnei 2015-08-26 18:44:52 -04:00
commit 32e279c0ca
1 changed files with 38 additions and 56 deletions

View File

@ -49,65 +49,47 @@ enum {
typedef unsigned int (*shtop_fp_t)(ARMul_State* cpu, unsigned int sht_oper); typedef unsigned int (*shtop_fp_t)(ARMul_State* cpu, unsigned int sht_oper);
static int CondPassed(ARMul_State* cpu, unsigned int cond) { static bool CondPassed(ARMul_State* cpu, unsigned int cond) {
const u32 NFLAG = cpu->NFlag; const bool n_flag = cpu->NFlag != 0;
const u32 ZFLAG = cpu->ZFlag; const bool z_flag = cpu->ZFlag != 0;
const u32 CFLAG = cpu->CFlag; const bool c_flag = cpu->CFlag != 0;
const u32 VFLAG = cpu->VFlag; const bool v_flag = cpu->VFlag != 0;
int temp = 0;
switch (cond) { switch (cond) {
case 0x0: case ConditionCode::EQ:
temp = ZFLAG; return z_flag;
break; case ConditionCode::NE:
case 0x1: // NE return !z_flag;
temp = !ZFLAG; case ConditionCode::CS:
break; return c_flag;
case 0x2: // CS case ConditionCode::CC:
temp = CFLAG; return !c_flag;
break; case ConditionCode::MI:
case 0x3: // CC return n_flag;
temp = !CFLAG; case ConditionCode::PL:
break; return !n_flag;
case 0x4: // MI case ConditionCode::VS:
temp = NFLAG; return v_flag;
break; case ConditionCode::VC:
case 0x5: // PL return !v_flag;
temp = !NFLAG; case ConditionCode::HI:
break; return (c_flag && !z_flag);
case 0x6: // VS case ConditionCode::LS:
temp = VFLAG; return (!c_flag || z_flag);
break; case ConditionCode::GE:
case 0x7: // VC return (n_flag == v_flag);
temp = !VFLAG; case ConditionCode::LT:
break; return (n_flag != v_flag);
case 0x8: // HI case ConditionCode::GT:
temp = (CFLAG && !ZFLAG); return (!z_flag && (n_flag == v_flag));
break; case ConditionCode::LE:
case 0x9: // LS return (z_flag || (n_flag != v_flag));
temp = (!CFLAG || ZFLAG); case ConditionCode::AL:
break; case ConditionCode::NV: // Unconditional
case 0xa: // GE return true;
temp = ((!NFLAG && !VFLAG) || (NFLAG && VFLAG));
break;
case 0xb: // LT
temp = ((NFLAG && !VFLAG) || (!NFLAG && VFLAG));
break;
case 0xc: // GT
temp = ((!NFLAG && !VFLAG && !ZFLAG) || (NFLAG && VFLAG && !ZFLAG));
break;
case 0xd: // LE
temp = ((NFLAG && !VFLAG) || (!NFLAG && VFLAG)) || ZFLAG;
break;
case 0xe: // AL
temp = 1;
break;
case 0xf:
temp = 1;
break;
} }
return temp;
return false;
} }
static unsigned int DPO(Immediate)(ARMul_State* cpu, unsigned int sht_oper) { static unsigned int DPO(Immediate)(ARMul_State* cpu, unsigned int sht_oper) {