Exemplo n.º 1
0
        private Instructions.Instruction[] mapUnprefixedInstructions()
        {
            Instructions.Instruction[] instructions = new Instructions.Instruction[256];

            instructions[0x00] = Instructions.Ox0_0_noop;

            instructions[0x01] = Instructions.Ox0_1_LD_BC_D16;

            instructions[0x02] = Instructions.Ox0_2_LD_M_BC_A;

            instructions[0x03] = Instructions.Ox0_3_INC_BC;

            instructions[0x04] = Instructions.Ox0_4_INC_B;

            instructions[0x05] = Instructions.Ox0_5_DEC_B;


            return(instructions);
        }
Exemplo n.º 2
0
        //Start execution of the program
        public void run()
        {
            //Setup running environment
            Console.Out.WriteLine("Setting up environment...");

            //Create the initial stack frame
            StackFrame initialStackFrame = new StackFrame();

            //Setup the stack with the initial stack frame `initialStackFrame`
            stack = new Stack(initialStackFrame);

            //Setup the heap
            heap = new Heap();

            //Begin execution of the program
            Console.Out.WriteLine("Environment all setup, beginning execution of program...");

            //Execution begins with the entry block which would be the first block in the ProgramData and hence the currentBlock
            Block entryBlock = programData.getCurrentBlock();

            //Loop through each instruction of the entryBlock and execute them whilst the instruction pointer is (//TODO)
            while (true)
            {
                //Get the current block being executed
                //Note: On first run this block will be the `entryBlock` (the first in the List<Block>)
                Block currentBlock = programData.getCurrentBlock();

                //Execute the instruction in the block `currentBlock` pointed to by the instruction pointer in the block `currentBlock`
                Instructions.Instruction currentInstruction = currentBlock.getCurrentInstruction();
                bool errored = currentInstruction.execute();

                //After execution check if the program must still be running (or has been set to false and hence an error occurred)
                if (errored)
                {
                    Console.Out.WriteLine("An error occurred somewhere in executing the instruction and the interpreter will now halt.");
                    break;
                }
            }
            Console.Out.WriteLine("Code run completed");
        }
Exemplo n.º 3
0
 public DataPiece(Instructions.Instruction mInstruction, string mData)
 {
     Data        = mData;
     Instruction = mInstruction;
 }