Exemplo n.º 1
0
void Interpreter::BasicUnaryArithmetic(const Instruction & instruction,
    std::function<UInt16(UInt16)> ins)
{
    UInt16 val = mCPU.DumpRegister(instruction.GetSecondOperand());

    mErrorCode = mCPU.SetRegister(instruction.GetFirstOperand(), ins(val));
    mCPU.SetSignZeroFlag(mCPU.DumpRegister(instruction.GetFirstOperand()));
}
Exemplo n.º 2
0
void Interpreter::JME(const Instruction & instruction)
{
    UInt16 xVal = mCPU.DumpRegister(instruction.GetFirstOperand());
    UInt16 yVal = mCPU.DumpRegister(instruction.GetSecondOperand());
    if(xVal == yVal)
        mErrorCode = mCPU.SetProgramCounter(instruction.GetImmediateValue());
}
Exemplo n.º 3
0
void Interpreter::IndirectLDM(const Instruction & instruction)
{
    UInt8 addrX = instruction.GetFirstOperand();
    UInt8 addrY = instruction.GetSecondOperand();
    UInt16 val;
    mErrorCode = mCPU.Load(mCPU.DumpRegister(addrY), val);
    mErrorCode = mCPU.SetRegister(addrX, val);
}
Exemplo n.º 4
0
void Interpreter::DirectLDM(const Instruction & instruction)
{
    UInt8 addr = instruction.GetFirstOperand();
    UInt16 iVal = instruction.GetImmediateValue();
    UInt16 val;
    mErrorCode = mCPU.Load(iVal, val);
    mErrorCode |= mCPU.SetRegister(addr, val);
}
Exemplo n.º 5
0
void Interpreter::RND(const Instruction & instruction)
{
    UInt8 addr = instruction.GetFirstOperand();
    UInt16 maxVal = instruction.GetImmediateValue();
    UInt16 randVal = mDist(mRandEngine);
    while(randVal > maxVal)
        randVal= mDist(mRandEngine);
    mErrorCode = mCPU.SetRegister(addr, randVal);
}
Exemplo n.º 6
0
void Interpreter::Cx(const Instruction & instruction)
{
    UInt8 condCode = instruction.GetFirstOperand();
    if(InterpretConditions(condCode))
    {
        mErrorCode = mCPU.PushPC();
        mErrorCode |= mCPU.SetProgramCounter(instruction.GetImmediateValue());
    }
}
Exemplo n.º 7
0
void Interpreter::InplaceUnaryArithmetic(const Instruction & instruction,
    std::function<UInt16(UInt16)> ins)
{
    UInt8 reg = instruction.GetFirstOperand();
    UInt16 val = mCPU.DumpRegister(reg);

    mErrorCode = mCPU.SetRegister(reg, ins(val));
    mCPU.SetSignZeroFlag(mCPU.DumpRegister(reg));
}
Exemplo n.º 8
0
void Interpreter::DiscardImmediateBinaryArithmetic(const Instruction & instruction,
                                             std::function<UInt16(UInt16,UInt16)> ins, 
                                             std::function<void(UInt16,UInt16)> frh)
{
    UInt16 xVal = mCPU.DumpRegister(instruction.GetFirstOperand());
    UInt16 iVal = instruction.GetImmediateValue();

    if (frh)
        frh(xVal, iVal);

    UInt16 result = ins(xVal, iVal);
    mCPU.SetSignZeroFlag(result);
}
Exemplo n.º 9
0
void Interpreter::ImmediateBinaryArithmetic(const Instruction & instruction,
                                      std::function<UInt16(UInt16,UInt16)> ins, 
                                      std::function<void(UInt16,UInt16)> frh)
{
    UInt8 reg = instruction.GetFirstOperand();
    UInt16 iVal = instruction.GetImmediateValue();

    if (frh)
        frh(mCPU.DumpRegister(reg), iVal);
    
    mErrorCode = mCPU.SetRegister(reg, ins(mCPU.DumpRegister(reg), iVal));
    mCPU.SetSignZeroFlag(mCPU.DumpRegister(reg));
}
Exemplo n.º 10
0
void Interpreter::InplaceBinaryArithmetic(const Instruction & instruction,
                                    std::function<UInt16(UInt16,UInt16)> ins, 
                                    std::function<void(UInt16,UInt16)> frh)
{
    UInt8 xReg = instruction.GetFirstOperand();
    UInt16 xVal = mCPU.DumpRegister(xReg);
    UInt16 yVal = mCPU.DumpRegister(instruction.GetSecondOperand());
    
    if (frh)
        frh(xVal, yVal);

    mErrorCode = mCPU.SetRegister(xReg, ins(xVal, yVal));
    mCPU.SetSignZeroFlag(mCPU.DumpRegister(xReg));
}
Exemplo n.º 11
0
void Interpreter::PUSH(const Instruction & instruction)
{
    mErrorCode = mCPU.Push(mCPU.DumpRegister(instruction.GetFirstOperand()));
}
Exemplo n.º 12
0
void Interpreter::RegisterLDI(const Instruction & instruction)
{
    mErrorCode = mCPU.SetRegister(instruction.GetFirstOperand(), instruction.GetImmediateValue());
}
Exemplo n.º 13
0
void Interpreter::IndirectCALL(const Instruction & instruction)
{
    mErrorCode = mCPU.PushPC();
    mErrorCode |= mCPU.SetProgramCounter(mCPU.DumpRegister(instruction.GetFirstOperand()));
}
Exemplo n.º 14
0
void Interpreter::IndirectSTM(const Instruction & instruction)
{
    UInt16 xVal = mCPU.DumpRegister(instruction.GetFirstOperand());
    UInt16 yVal = mCPU.DumpRegister(instruction.GetSecondOperand());
    mErrorCode = mCPU.Store(yVal, xVal);
}
Exemplo n.º 15
0
void Interpreter::DirectSTM(const Instruction & instruction)
{
    UInt8 regAddr = instruction.GetFirstOperand();
    UInt16 memAddr = instruction.GetImmediateValue();
    mErrorCode = mCPU.Store(memAddr, mCPU.DumpRegister(regAddr));
}
Exemplo n.º 16
0
void Interpreter::RegisterSAR(const Instruction & instruction)
{
    UInt8 addr = instruction.GetFirstOperand();
    mErrorCode = mCPU.SetRegister(addr, ArithmeticRightShift()(mCPU.DumpRegister(addr), mCPU.DumpRegister(instruction.GetSecondOperand())));
    mCPU.SetSignZeroFlag(mCPU.DumpRegister(addr));
}
Exemplo n.º 17
0
void Interpreter::NSHR(const Instruction & instruction)
{
    UInt8 addr = instruction.GetFirstOperand();
    mErrorCode = mCPU.SetRegister(addr, LogicalRightShift()(mCPU.DumpRegister(addr), instruction.GetThirdOperand()));
    mCPU.SetSignZeroFlag(mCPU.DumpRegister(addr));
}
Exemplo n.º 18
0
void Interpreter::MOV(const Instruction & instruction)
{
    UInt8 addrX = instruction.GetFirstOperand();
    UInt16 yVal = mCPU.DumpRegister(instruction.GetSecondOperand()); 
    mErrorCode = mCPU.SetRegister(addrX, yVal);
}
Exemplo n.º 19
0
void Interpreter::POP(const Instruction & instruction)
{
    UInt16 val;
    mErrorCode = mCPU.Pop(val);
    mErrorCode |= mCPU.SetRegister(instruction.GetFirstOperand(), val);
}
Exemplo n.º 20
0
void Interpreter::Jx(const Instruction & instruction)
{
    UInt8 condCode = instruction.GetFirstOperand();
    if(InterpretConditions(condCode))
        mCPU.SetProgramCounter(instruction.GetImmediateValue());
}