Пример #1
0
        private static void UnconditionalJumpAction(
            CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
        {
            const Boolean Condition = true;

            DoJump(Condition, operand, registerSet.PR);
        }
Пример #2
0
        private static void JumpOnNonZeroAction(
            CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
        {
            Boolean condition = !registerSet.FR.ZF;

            DoJump(condition, operand, registerSet.PR);
        }
Пример #3
0
        private static void JumpOnOverflowAction(
            CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
        {
            Boolean condition = registerSet.FR.OF;

            DoJump(condition, operand, registerSet.PR);
        }
Пример #4
0
        /// <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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        private static void LoadWithFrAction(
            CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
        {
            r.Value = operand;
            const Boolean OverflowFlag = false;

            registerSet.FR.SetFlags(r, OverflowFlag);
        }
Пример #7
0
        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);
        }
Пример #8
0
        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;
        }
Пример #9
0
        private static Word GetEaContents(UInt16 xR2Field, CpuRegisterSet registerSet, Memory memory)
        {
            // 実効アドレスの内容を取得します。
            Word effectiveAddress = GetEffectiveAddress(xR2Field, registerSet, memory);
            Word eaContents       = memory.Read(effectiveAddress);

            return(eaContents);
        }
Пример #10
0
        private void SetupRegisterSet(MemoryAddress execStartAddress)
        {
            // PR をプログラムの開始アドレスに、SP をスタック領域の最後のアドレス + 1 に、それぞれ設定する。
            CpuRegisterSet registerSet = m_cpu.RegisterSet;

            registerSet.Reset();
            registerSet.PR.Value = execStartAddress.GetValueAsWord();
            registerSet.SP.Value = InitialSp;
        }
Пример #11
0
 private static Word GetAddressOffset(UInt16 xR2Field, CpuRegisterSet registerSet)
 {
     if (xR2Field == 0)
     {
         return(Word.Zero);
     }
     else
     {
         return(DoGetRegister(xR2Field, registerSet));
     }
 }
Пример #12
0
        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);
            }
        }
Пример #13
0
        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);
        }
Пример #14
0
 private static void LoadWithoutFrAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     r.Value = operand;
 }
Пример #15
0
 /// <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);
 }
Пример #16
0
 private static void StoreAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     memory.Write(operand, r.Value);
 }
Пример #17
0
 private static void NoOperationAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     //
 }
Пример #18
0
 private static void SuperVisorCallAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     OnCallingSuperVisor(operand);
 }
Пример #19
0
 private static void CompareArithmeticAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     DoCompare(Alu.CompareArithmetic, r, operand, registerSet.FR);
 }
Пример #20
0
 private static void XorAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     DoLogic(Alu.Xor, r, operand, registerSet.FR, memory);
 }
Пример #21
0
 private static void CompareLogicalAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     DoCompare(Alu.CompareLogical, r, operand, registerSet.FR);
 }
Пример #22
0
 private static void SubtractArithmeticAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     DoOperation(Alu.SubtractArithmetic, r, operand, registerSet.FR, memory);
 }
Пример #23
0
 private static void ShiftLeftArithmeticAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     DoShift(Alu.ShiftLeftArithmetic, r, operand, registerSet.FR);
 }
Пример #24
0
 private static CpuRegister GetNoRegister(UInt16 rR1Field, CpuRegisterSet registerSet)
 {
     return(null);
 }
Пример #25
0
        /// <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);
        }
Пример #26
0
 private static void ShiftRightLogicalAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     DoShift(Alu.ShiftRightLogical, r, operand, registerSet.FR);
 }
Пример #27
0
 private static void AddLogicalAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     DoOperation(Alu.AddLogical, r, operand, registerSet.FR, memory);
 }
Пример #28
0
 private static void PushAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     PushValue(registerSet.SP, memory, operand);
 }
Пример #29
0
 private static void PopAction(
     CpuRegister r, Word operand, CpuRegisterSet registerSet, Memory memory)
 {
     r.Value = PopValue(registerSet.SP, memory);
 }
Пример #30
0
 /// <summary>
 /// 指定の主記憶を使って <see cref="Cpu"/> のインスタンスを初期化します。
 /// </summary>
 /// <param name="memory">COMET II の主記憶です。</param>
 internal Cpu(Memory memory)
 {
     m_registerSet = new CpuRegisterSet();
     m_memory      = memory;
 }