Esempio n. 1
0
        public void GetInstruction4Test()
        {
            long[] program       = { 00004, 50, 0 };
            var    instruction03 = InstructionUtils.GetInstruction(program, 0, new ConsoleInput(), new ConsoleOutput(), null) as Instruction04;

            Assert.NotNull(instruction03);
        }
Esempio n. 2
0
        public void GetInstruction2Test()
        {
            long[] program       = { 00002, 1, 1, 1 };
            var    instruction02 = InstructionUtils.GetInstruction(program, 0, new ConsoleInput(), new ConsoleOutput(), null) as Instruction02;

            Assert.NotNull(instruction02);
        }
Esempio n. 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     ssm.Reset();
     ssm.instructions.Clear();
     ssm.Compile(textBox1.Text);
     begintime = InstructionUtils.GetTimestamp();
     ssm.Run();
 }
Esempio n. 4
0
        public void ExecuteInstruction3Test()
        {
            long[]           program          = { 10002, 2, 2, 1 };
            MemoryController memoryController = new MemoryController(program);
            long             pc = 0;
            var instruction02   = InstructionUtils.GetInstruction(program, 0, new ConsoleInput(), new ConsoleOutput(), memoryController);

            instruction02?.Execute(program, ref pc);

            Assert.Equal(4, program[3]);
        }
Esempio n. 5
0
        public void ExecuteInstruction2Test()
        {
            long[]           program          = { 1002, 4, 3, 4, 33 };
            long[]           expected         = { 1002, 4, 3, 4, 99 };
            MemoryController memoryController = new MemoryController(program);
            long             pc = 0;
            var instruction01   = InstructionUtils.GetInstruction(program, 0, new ConsoleInput(), new ConsoleOutput(), memoryController);

            instruction01?.Execute(program, ref pc);

            Assert.Equal(expected, program);
        }
Esempio n. 6
0
        public void ExecuteInstruction1Test()
        {
            long[] program = new long[] { 10001, 1, 1, 1 };
            long   pc      = 0;

            MemoryController memoryController = new MemoryController(program);
            var instruction01 = InstructionUtils.GetInstruction(program, 0, new ConsoleInput(), new ConsoleOutput(), memoryController);

            instruction01?.Execute(program, ref pc);

            Assert.Equal(2, program[3]);
        }
Esempio n. 7
0
 private void run()
 {
     while (isStarted)
     {
         if (mBomber.perform())
         {
             mSuccessCount++;
         }
         else
         {
             Thread.Sleep(InstructionUtils.Rnd().Next() % 1500 + 500);
         }
     }
 }
Esempio n. 8
0
        private void Ssm_OnProgramFinish(object sender, StackStateMachine e)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("栈区内容:\r\n");
            foreach (string s in e.runtimeStack)
            {
                sb.Append(TextUtil.escapeText(s)).Append("\r\n");
            }

            sb.Append("\r\n寄存器内容:\r\n");
            foreach (KeyValuePair <string, string> s in e.runtimeRegister)
            {
                sb.Append(s.Key + ":" + TextUtil.escapeText(s.Value)).Append("\r\n");
            }

            sb.Append("\r\n用时:" + (InstructionUtils.GetTimestamp() - begintime).ToString() + "ms");

            MessageBox.Show(sb.ToString(), "程序结束");
        }
Esempio n. 9
0
 protected InstructionBase(long instructionCode, IMemoryController memoryController)
 {
     _memoryController = memoryController;
     Modes             = InstructionUtils.ParseParameterMode(instructionCode);
 }