core/x86/instr.c
/* Given eflags, returns whether or not the conditional branch opc would be taken */
Given eflags, returns whether or not the conditional branch opc would be taken
Given eflags returns whether or not the conditional branch opc would be taken
static bool
opc_jcc_taken(int opc, reg_t eflags)
{
    switch (opc) {
    case OP_jo: case OP_jo_short:
        return TEST(EFLAGS_OF, eflags);
    case OP_jno: case OP_jno_short:
        return !TEST(EFLAGS_OF, eflags);
    case OP_jb: case OP_jb_short: 
        return TEST(EFLAGS_CF, eflags);
    case OP_jnb: case OP_jnb_short:
        return !TEST(EFLAGS_CF, eflags);
    case OP_jz: case OP_jz_short: 
        return TEST(EFLAGS_ZF, eflags);
    case OP_jnz: case OP_jnz_short:
        return !TEST(EFLAGS_ZF, eflags);
    case OP_jbe: case OP_jbe_short:
        return TESTANY(EFLAGS_CF | EFLAGS_ZF, eflags);
    case OP_jnbe: case OP_jnbe_short:
        return !TESTANY(EFLAGS_CF | EFLAGS_ZF, eflags);
    case OP_js: case OP_js_short: 
        return TEST(EFLAGS_SF, eflags);
    case OP_jns: case OP_jns_short:
        return !TEST(EFLAGS_SF, eflags);
    case OP_jp: case OP_jp_short: 
        return TEST(EFLAGS_PF, eflags);
    case OP_jnp: case OP_jnp_short:
        return !TEST(EFLAGS_PF, eflags);
    case OP_jl: case OP_jl_short: 
        return (TEST(EFLAGS_SF, eflags) != TEST(EFLAGS_OF, eflags));
    case OP_jnl: case OP_jnl_short:
        return (TEST(EFLAGS_SF, eflags) == TEST(EFLAGS_OF, eflags));
    case OP_jle: case OP_jle_short:
        return (TEST(EFLAGS_ZF, eflags) ||
                TEST(EFLAGS_SF, eflags) != TEST(EFLAGS_OF, eflags));
    case OP_jnle: case OP_jnle_short:
        return (!TEST(EFLAGS_ZF, eflags) &&
                TEST(EFLAGS_SF, eflags) == TEST(EFLAGS_OF, eflags));
    default:
        CLIENT_ASSERT(false, "instr_jcc_taken: unknown opcode");
        return false;
    }
}
static bool opc_jcc_taken ( int opc , reg_t eflags ) { switch ( opc ) { case OP_jo : case OP_jo_short : return TEST ( EFLAGS_OF , eflags ) ; case OP_jno : case OP_jno_short : return ! TEST ( EFLAGS_OF , eflags ) ; case OP_jb : case OP_jb_short : return TEST ( EFLAGS_CF , eflags ) ; case OP_jnb : case OP_jnb_short : return ! TEST ( EFLAGS_CF , eflags ) ; case OP_jz : case OP_jz_short : return TEST ( EFLAGS_ZF , eflags ) ; case OP_jnz : case OP_jnz_short : return ! TEST ( EFLAGS_ZF , eflags ) ; case OP_jbe : case OP_jbe_short : return TESTANY ( EFLAGS_CF | EFLAGS_ZF , eflags ) ; case OP_jnbe : case OP_jnbe_short : return ! TESTANY ( EFLAGS_CF | EFLAGS_ZF , eflags ) ; case OP_js : case OP_js_short : return TEST ( EFLAGS_SF , eflags ) ; case OP_jns : case OP_jns_short : return ! TEST ( EFLAGS_SF , eflags ) ; case OP_jp : case OP_jp_short : return TEST ( EFLAGS_PF , eflags ) ; case OP_jnp : case OP_jnp_short : return ! TEST ( EFLAGS_PF , eflags ) ; case OP_jl : case OP_jl_short : return ( TEST ( EFLAGS_SF , eflags ) != TEST ( EFLAGS_OF , eflags ) ) ; case OP_jnl : case OP_jnl_short : return ( TEST ( EFLAGS_SF , eflags ) == TEST ( EFLAGS_OF , eflags ) ) ; case OP_jle : case OP_jle_short : return ( TEST ( EFLAGS_ZF , eflags ) || TEST ( EFLAGS_SF , eflags ) != TEST ( EFLAGS_OF , eflags ) ) ; case OP_jnle : case OP_jnle_short : return ( ! TEST ( EFLAGS_ZF , eflags ) && TEST ( EFLAGS_SF , eflags ) == TEST ( EFLAGS_OF , eflags ) ) ; default : CLIENT_ASSERT ( false , " " ) ; return false ; } }
Given eflags, returns whether or not the conditional branch opc would be taken
Given eflags returns whether or not the conditional branch opc would be taken