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()); }
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); }
void Interpreter::ImmediateUnaryArithmetic(const Instruction & instruction, std::function<UInt16(UInt16)> ins) { UInt8 reg = instruction.GetFirstOperand(); UInt16 iVal = instruction.GetImmediateValue(); mErrorCode = mCPU.SetRegister(reg, ins(iVal)); mCPU.SetSignZeroFlag(mCPU.DumpRegister(reg)); }
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); }
void Interpreter::Cx(const Instruction & instruction) { UInt8 condCode = instruction.GetFirstOperand(); if(InterpretConditions(condCode)) { mErrorCode = mCPU.PushPC(); mErrorCode |= mCPU.SetProgramCounter(instruction.GetImmediateValue()); } }
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); }
void Interpreter::DirectSTM(const Instruction & instruction) { UInt8 regAddr = instruction.GetFirstOperand(); UInt16 memAddr = instruction.GetImmediateValue(); mErrorCode = mCPU.Store(memAddr, mCPU.DumpRegister(regAddr)); }
void Interpreter::StackLDI(const Instruction & instruction) { mErrorCode = mCPU.SetStackPointer(instruction.GetImmediateValue()); }
void Interpreter::RegisterLDI(const Instruction & instruction) { mErrorCode = mCPU.SetRegister(instruction.GetFirstOperand(), instruction.GetImmediateValue()); }
void Interpreter::DirectCALL(const Instruction & instruction) { mErrorCode = mCPU.PushPC(); mErrorCode |= mCPU.SetProgramCounter(instruction.GetImmediateValue()); }
void Interpreter::Jx(const Instruction & instruction) { UInt8 condCode = instruction.GetFirstOperand(); if(InterpretConditions(condCode)) mCPU.SetProgramCounter(instruction.GetImmediateValue()); }
void Interpreter::JMC(const Instruction & instruction) { if (mCPU.DumpFlagRegister() & CPU::UNSIGNED_CARRY_FLAG) mErrorCode = mCPU.SetProgramCounter(instruction.GetImmediateValue()); }
void Interpreter::DirectJMP(const Instruction & instruction) { mErrorCode = mCPU.SetProgramCounter(instruction.GetImmediateValue()); }