private static void UnconditionalJumpAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { const Boolean Condition = true; DoJump(Condition, operand, registerSet.PR); }
private static void JumpOnNonZeroAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { Boolean condition = !registerSet.FR.ZF; DoJump(condition, operand, registerSet.PR); }
private static void JumpOnOverflowAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { Boolean condition = registerSet.FR.OF; DoJump(condition, operand, registerSet.PR); }
/// <summary> /// 命令を実行します。 /// </summary> /// <param name="rR1Field">命令語の中の r/r1 フィールドの値です。</param> /// <param name="xR2Field">命令語の中の x/r2 フィールドの値です。</param> /// <param name="registerSet">COMET II の一そろいのレジスタです。</param> /// <param name="memory">COMET II の主記憶です。</param> internal void Execute(UInt16 rR1Field, UInt16 xR2Field, CpuRegisterSet registerSet, Memory memory) { CpuRegister r = m_registerHandler.GetRegister(rR1Field, registerSet); Word operand = m_operandHandler.GetOperand(xR2Field, registerSet, memory); m_operator.Operate(r, operand, registerSet, memory); }
private static Word DoGetRegister(UInt16 xR2Field, CpuRegisterSet registerSet) { ArgChecker.CheckRange(xR2Field, 0, RegisterDef.GrCount - 1, "x/r2"); CpuRegister x = registerSet.GR[xR2Field]; return(x.Value); }
private static void LoadWithFrAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { r.Value = operand; const Boolean OverflowFlag = false; registerSet.FR.SetFlags(r, OverflowFlag); }
private static void JumpOnPlusAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { FlagRegister fr = registerSet.FR; Boolean condition = (!fr.SF && !fr.ZF); DoJump(condition, operand, registerSet.PR); }
private static void CallSubroutineAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { CpuRegister pr = registerSet.PR; PushValue(registerSet.SP, memory, pr.Value); pr.Value = operand; }
private static Word GetEaContents(UInt16 xR2Field, CpuRegisterSet registerSet, Memory memory) { // 実効アドレスの内容を取得します。 Word effectiveAddress = GetEffectiveAddress(xR2Field, registerSet, memory); Word eaContents = memory.Read(effectiveAddress); return(eaContents); }
private void SetupRegisterSet(MemoryAddress execStartAddress) { // PR をプログラムの開始アドレスに、SP をスタック領域の最後のアドレス + 1 に、それぞれ設定する。 CpuRegisterSet registerSet = m_cpu.RegisterSet; registerSet.Reset(); registerSet.PR.Value = execStartAddress.GetValueAsWord(); registerSet.SP.Value = InitialSp; }
private static Word GetAddressOffset(UInt16 xR2Field, CpuRegisterSet registerSet) { if (xR2Field == 0) { return(Word.Zero); } else { return(DoGetRegister(xR2Field, registerSet)); } }
private static void ReturnFromSubroutineAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { Boolean cancel = OnReturningFromSubroutine(registerSet.SP); if (!cancel) { CpuRegister pr = registerSet.PR; pr.Value = PopValue(registerSet.SP, memory); } }
private static Word GetEffectiveAddress(UInt16 xR2Field, CpuRegisterSet registerSet, Memory memory) { // プログラムカウンタの指すアドレスより adr を取得します。 Word adr = Fetcher.Fetch(registerSet.PR, memory); // x/r2 フィールドの値よりオフセット x の値を取得し、実効アドレス adr +L x を計算します。 Word x = GetAddressOffset(xR2Field, registerSet); Word effectiveAddress = Alu.AddLogical(adr, x); return(effectiveAddress); }
private static void LoadWithoutFrAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { r.Value = operand; }
/// <summary> /// 演算を実行します。 /// </summary> /// <param name="r">演算に使用するレジスタです。</param> /// <param name="operand">演算対象の値を保持する語です。</param> /// <param name="registerSet">COMET II の一そろいのレジスタです。</param> /// <param name="memory">COMET II の主記憶です。</param> internal void Operate(CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { m_operateAction(r, operand, registerSet, memory); }
private static void StoreAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { memory.Write(operand, r.Value); }
private static void NoOperationAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { // }
private static void SuperVisorCallAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { OnCallingSuperVisor(operand); }
private static void CompareArithmeticAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { DoCompare(Alu.CompareArithmetic, r, operand, registerSet.FR); }
private static void XorAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { DoLogic(Alu.Xor, r, operand, registerSet.FR, memory); }
private static void CompareLogicalAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { DoCompare(Alu.CompareLogical, r, operand, registerSet.FR); }
private static void SubtractArithmeticAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { DoOperation(Alu.SubtractArithmetic, r, operand, registerSet.FR, memory); }
private static void ShiftLeftArithmeticAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { DoShift(Alu.ShiftLeftArithmetic, r, operand, registerSet.FR); }
private static CpuRegister GetNoRegister(UInt16 rR1Field, CpuRegisterSet registerSet) { return(null); }
/// <summary> /// 命令で指定するレジスタを取得します。 /// </summary> /// <param name="rR1Field">命令語の中の r/r1 フィールドの値です。</param> /// <param name="registerSet">COMET II の一そろいのレジスタです。</param> /// <returns> /// 命令で指定するレジスタを返します。 /// 指定するレジスタがない場合は <see langword="null"/> を返します。 /// </returns> internal CpuRegister GetRegister(UInt16 rR1Field, CpuRegisterSet registerSet) { CpuRegister r = m_getRegisterAction(rR1Field, registerSet); return(r); }
private static void ShiftRightLogicalAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { DoShift(Alu.ShiftRightLogical, r, operand, registerSet.FR); }
private static void AddLogicalAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { DoOperation(Alu.AddLogical, r, operand, registerSet.FR, memory); }
private static void PushAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { PushValue(registerSet.SP, memory, operand); }
private static void PopAction( CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory) { r.Value = PopValue(registerSet.SP, memory); }
/// <summary> /// 指定の主記憶を使って <see cref="Cpu"/> のインスタンスを初期化します。 /// </summary> /// <param name="memory">COMET II の主記憶です。</param> internal Cpu(Memory memory) { m_registerSet = new CpuRegisterSet(); m_memory = memory; }