コード例 #1
0
        public static int[] Seti(int[] registers, InstructionTest process)
        {
            // seti (set immediate) stores value A into register C. (Input B is ignored.)
            registers[process.Instruction[3]] = process.Instruction[1];

            return(registers);
        }
コード例 #2
0
        public static int[] Bori(int[] registers, InstructionTest process)
        {
            // bori (bitwise OR immediate) stores into register C the result of the bitwise OR of register A and value B.
            registers[process.Instruction[3]] = registers[process.Instruction[1]] | process.Instruction[2];

            return(registers);
        }
コード例 #3
0
        public static int[] Setr(int[] registers, InstructionTest process)
        {
            // setr (set register) copies the contents of register A into register C. (Input B is ignored.)
            registers[process.Instruction[3]] = registers[process.Instruction[1]];

            return(registers);
        }
コード例 #4
0
        public static int[] Addr(int[] registers, InstructionTest process)
        {
            // addr (add register) stores into register C the result of adding register A and register B.
            registers[process.Instruction[3]] = registers[process.Instruction[1]] + registers[process.Instruction[2]];

            return(registers);
        }
コード例 #5
0
        public static int[] Borr(int[] registers, InstructionTest process)
        {
            // borr (bitwise OR register) stores into register C the result of the bitwise OR of register A and register B.
            registers[process.Instruction[3]] = registers[process.Instruction[1]] | registers[process.Instruction[2]];

            return(registers);
        }
コード例 #6
0
        public static int[] Mulr(int[] registers, InstructionTest process)
        {
            // mulr (multiply register) stores into register C the result of multiplying register A and register B.
            registers[process.Instruction[3]] = registers[process.Instruction[1]] * registers[process.Instruction[2]];

            return(registers);
        }
コード例 #7
0
        public static int[] Muli(int[] registers, InstructionTest process)
        {
            // muli (multiply immediate) stores into register C the result of multiplying register A and value B.
            registers[process.Instruction[3]] = registers[process.Instruction[1]] * process.Instruction[2];

            return(registers);
        }
コード例 #8
0
        public static int[] Addi(int[] registers, InstructionTest process)
        {
            // addi (add immediate) stores into register C the result of adding register A and value B.
            registers[process.Instruction[3]] = registers[process.Instruction[1]] + process.Instruction[2];

            return(registers);
        }
コード例 #9
0
        public static int[] Gtri(int[] registers, InstructionTest process)
        {
            // gtri (greater-than register/immediate) sets register C to 1 if register A is greater than value B. Otherwise, register C is set to 0.
            if (registers[process.Instruction[1]] > process.Instruction[2])
            {
                registers[process.Instruction[3]] = 1;
            }
            else
            {
                registers[process.Instruction[3]] = 0;
            }

            return(registers);
        }
コード例 #10
0
        public static int[] Gtir(int[] registers, InstructionTest process)
        {
            // gtir (greater-than immediate/register) sets register C to 1 if value A is greater than register B. Otherwise, register C is set to 0.
            if (process.Instruction[1] > registers[process.Instruction[2]])
            {
                registers[process.Instruction[3]] = 1;
            }
            else
            {
                registers[process.Instruction[3]] = 0;
            }

            return(registers);
        }
コード例 #11
0
        public static int[] Eqrr(int[] registers, InstructionTest process)
        {
            // eqrr (equal register/register) sets register C to 1 if register A is equal to register B. Otherwise, register C is set to 0.
            if (registers[process.Instruction[1]] == registers[process.Instruction[2]])
            {
                registers[process.Instruction[3]] = 1;
            }
            else
            {
                registers[process.Instruction[3]] = 0;
            }

            return(registers);
        }
コード例 #12
0
        public static int[] Eqri(int[] registers, InstructionTest process)
        {
            // eqri (equal register/immediate) sets register C to 1 if register A is equal to value B. Otherwise, register C is set to 0.
            if (registers[process.Instruction[1]] == process.Instruction[2])
            {
                registers[process.Instruction[3]] = 1;
            }
            else
            {
                registers[process.Instruction[3]] = 0;
            }

            return(registers);
        }
コード例 #13
0
        public static int[] Eqir(int[] registers, InstructionTest process)
        {
            // eqir (equal immediate/register) sets register C to 1 if value A is equal to register B. Otherwise, register C is set to 0.
            if (process.Instruction[1] == registers[process.Instruction[2]])
            {
                registers[process.Instruction[3]] = 1;
            }
            else
            {
                registers[process.Instruction[3]] = 0;
            }

            return(registers);
        }
コード例 #14
0
 public InstructionTestRunner(InstructionTest test)
 {
     _test = test;
 }