Ejemplo n.º 1
0
static mad_disasm_control Cond( mad_disasm_data *dd, int taken )
{
    if( !taken )
        return( MDC_JUMP | MDC_CONDITIONAL | MDC_TAKEN_NOT );
    return( (MDC_JUMP | MDC_CONDITIONAL) + Adjustment( dd ) );
}
Ejemplo n.º 2
0
mad_disasm_control DisasmControl( mad_disasm_data *dd, const mad_registers *mr )
{
    char            xor;
    unsigned long   val;

    xor = 0;
    switch( dd->ins.type ) {
    case DI_X86_int:
        return( MDC_SYSCALL | MDC_TAKEN );
    case DI_X86_call:
    case DI_X86_call2:
    case DI_X86_call3:
    case DI_X86_call4:
        return( MDC_CALL | MDC_TAKEN );
    case DI_X86_jmp:
    case DI_X86_jmp1:
        return( MDC_JUMP + Adjustment( dd ) );
    case DI_X86_iret:
    case DI_X86_iretd:
        return( MDC_SYSRET | MDC_TAKEN );
    case DI_X86_ret:
    case DI_X86_ret2:
    case DI_X86_retf:
    case DI_X86_retf2:
        return( MDC_RET | MDC_TAKEN );
    case DI_X86_jmp2:
    case DI_X86_jmp3:
    case DI_X86_jmp4:
        return( MDC_JUMP | MDC_TAKEN );
    case DI_X86_bound:
        return( MDC_OPER | MDC_TAKEN_NOT ); /* not supported yet */
    case DI_X86_jno:
    case DI_X86_jno2:
        xor = 1;
    case DI_X86_jo:
    case DI_X86_jo2:
        return Cond( dd, ( ( mr->x86.cpu.efl & FLG_O ) != 0 ) ^ xor );
    case DI_X86_jae:
    case DI_X86_jae2:
        xor = 1;
    case DI_X86_jb:
    case DI_X86_jb2:
        return Cond( dd, ( ( mr->x86.cpu.efl & FLG_C ) != 0 ) ^ xor );
    case DI_X86_jne:
    case DI_X86_jne2:
        xor = 1;
    case DI_X86_je:
    case DI_X86_je2:
        return Cond( dd, ( ( mr->x86.cpu.efl & FLG_Z ) != 0 ) ^ xor );
    case DI_X86_ja:
    case DI_X86_ja2:
        xor = 1;
    case DI_X86_jbe:
    case DI_X86_jbe2:
        return Cond( dd, ( ( mr->x86.cpu.efl & ( FLG_C | FLG_Z ) ) != 0 ) ^ xor );
    case DI_X86_jns:
    case DI_X86_jns2:
        xor = 1;
    case DI_X86_js:
    case DI_X86_js2:
        return Cond( dd, ( ( mr->x86.cpu.efl & FLG_S ) != 0 ) ^ xor );
    case DI_X86_jpo:
    case DI_X86_jpo2:
        xor = 1;
    case DI_X86_jp:
    case DI_X86_jp2:
        return Cond( dd, ( ( mr->x86.cpu.efl & FLG_P ) != 0 ) ^ xor );
    case DI_X86_jge:
    case DI_X86_jge2:
        xor = 1;
    case DI_X86_jl:
    case DI_X86_jl2:
        return Cond( dd, ( ( mr->x86.cpu.efl & FLG_S ) != 0 )
                ^ ( ( mr->x86.cpu.efl & FLG_O ) !=0 )
                ^ xor );
    case DI_X86_jg:
    case DI_X86_jg2:
        xor = 1;
    case DI_X86_jle:
    case DI_X86_jle2:
        return Cond( dd, ( ( ( ( mr->x86.cpu.efl & FLG_S ) != 0 )
                ^ ( ( mr->x86.cpu.efl & FLG_O ) != 0 ) )
                | ( ( mr->x86.cpu.efl & FLG_Z ) != 0 ) )
                ^ xor );
    case DI_X86_into:
        return( ( mr->x86.cpu.efl & FLG_O ) != 0
                ? ( MDC_SYSCALL|MDC_CONDITIONAL|MDC_TAKEN )
                : ( MDC_SYSCALL|MDC_CONDITIONAL|MDC_TAKEN_NOT ) );
    case DI_X86_loopnz:
        val= mr->x86.cpu.ecx;
        if( !( dd->ins.flags.u.x86 & DIF_X86_OPND_LONG ) )
            val &= 0xffff;
        return Cond( dd, ( mr->x86.cpu.efl & FLG_Z ) == 0 && val != 1 );
    case DI_X86_loopz:
        val= mr->x86.cpu.ecx;
        if( !( dd->ins.flags.u.x86 & DIF_X86_OPND_LONG ) )
            val &= 0xffff;
        return Cond( dd, ( mr->x86.cpu.efl & FLG_Z ) != 0 && val != 1 );
    case DI_X86_loop:
        val= mr->x86.cpu.ecx;
        if( !( dd->ins.flags.u.x86 & DIF_X86_OPND_LONG ) )
            val &= 0xffff;
        return Cond( dd, val != 1 );
    case DI_X86_jcxz:
    case DI_X86_jecxz:
        val= mr->x86.cpu.ecx;
        if( !( dd->ins.flags.u.x86 & DIF_X86_OPND_LONG ) )
            val &= 0xffff;
        return Cond( dd, val == 0 );
    default:
        break;
    }
    return( MDC_OPER | MDC_TAKEN_NOT );
}
Ejemplo n.º 3
0
Visualizer::Visualizer(const Repeater::Ptr& rep): mRepeater(rep),
                                                  mWidth(0),
                                                  mHeight(0),
                                                  mZoom(1),
                                                  mVolume(0),
                                                  mCurAdjustment(0),
						  mLastAdjustTime(0)
{
    mAdjustments.insert(
        std::make_pair(
            'f', Adjustment(
                "feedback",
                [](Repeater::Knobs& k, double a) -> double {
                    k.mode = Repeater::M_FEEDBACK;
                    double& tt = k.levels[k.mode];
                    tt += a/25;
                    return (tt = std::max(0.0, std::min(1.0, tt)));
                })
            )
        );
    mAdjustments.insert(
        std::make_pair(
            'F', Adjustment(
                "threshold",
                [](Repeater::Knobs& k, double a) -> double {
                    double& tt = k.feedbackThreshold;
                    tt *= 1 + a/10;
                    return (tt = std::max(1e-6, std::min(1.0, tt)));
                })
            )
        );
    mAdjustments.insert(
        std::make_pair(
            'g', Adjustment(
                "gain",
                [](Repeater::Knobs& k, double a) -> double {
                    k.mode = Repeater::M_GAIN;
                    double& tt = k.levels[k.mode];
                    tt += a/25;
                    return (tt = std::max(0.0, tt));
                })
            )
        );
    mAdjustments.insert(
        std::make_pair(
            't', Adjustment(
                "target",
                [](Repeater::Knobs& k, double a) -> double {
                    k.mode = Repeater::M_TARGET;
                    double& tt = k.levels[k.mode];
                    tt += a/25;
                    return (tt = std::max(0.0, std::min(1.0, tt)));
                })
            )
        );
    mAdjustments.insert(
        std::make_pair(
            'l', Adjustment(
                "limit",
                [](Repeater::Knobs& k, double a) -> double {
                    double& tt = k.limitPower;
                    tt += a/100;
                    return (tt = std::max(0.01, std::min(1.0, tt)));
                })
            )
        );
    mAdjustments.insert(
        std::make_pair(
            'd', Adjustment(
                "dampen",
                [](Repeater::Knobs& k, double a) -> double {
                    double& tt = k.dampen;
                    tt = (tt + (a + 1)/2)/2;
                    return (tt = std::max(0.0, std::min(1.0, tt)));
                })
            )
        );
}