Beispiel #1
0
            private void execute_single_instruction()
            {
                c_instruction current_instruction = instructions[instruction_pointer];

                current_instruction.visited = true;
                accumulator         += current_instruction.get_accumulator_increment();
                instruction_pointer += current_instruction.get_next_instruction_offset();
            }
Beispiel #2
0
            public void swap(int instruction_index_to_swap)
            {
                if (swapped_instruction != null)
                {
                    instructions[swapped_instruction_index] = swapped_instruction;
                }

                swapped_instruction_index = instruction_index_to_swap;
                swapped_instruction       = instructions[swapped_instruction_index];

                instructions[swapped_instruction_index] = swapped_instruction.swap_type();
            }
Beispiel #3
0
            public c_instruction swap_type()
            {
                c_instruction result = new c_instruction(this);

                switch (this.type)
                {
                case e_instruction_type.nop:
                    result.type = e_instruction_type.jmp;
                    break;

                case e_instruction_type.jmp:
                    result.type = e_instruction_type.nop;
                    break;

                default:
                    throw new Exception("Illecal swap");
                }

                return(result);
            }
Beispiel #4
0
 public c_instruction(c_instruction other)
 {
     this.type     = other.type;
     this.visited  = other.visited;
     this.argument = other.argument;
 }