示例#1
0
        public void Execute()
        {
            // get address of instruction to run
            var address = Memory.GetWord(Z.Read().NativeValue);

            // update Z
            Z.Increment();

            // we only care about 15-bit instructions
            var instruction = address.Read() & 0x7FFF;

            var code = (ushort)(instruction >> 12);
            var K    = (ushort)(instruction & 0xFFF);

            // determine if this is an extra code instruction
            if (ExtraCodeFlag)
            {
                // reset CPU for instruction to execute
                extraCodeInstructions[code].CPU = this;
                extraCodeInstructions[code].Execute(K);

                // clear the extra code flag
                ExtraCodeFlag = false;
            }
            else
            {
                // reset CPU for instruction to execute
                instructions[code].CPU = this;
                instructions[code].Execute(K);
            }
        }
示例#2
0
    /**
     * @brief Writes the content of a given register to the PC.
     * @param register - The register to be read from.
     */
    public IEnumerator WriteToPC(Register register)
    {
        if (PC.Equals(register))
        {
            busSystem.StartTransferringData(BusControl.BUS_ROUTE.PC_PC);
            yield return(new WaitForSeconds(clock.GetSpeed()));

            PC.Increment();
            busSystem.StopTransferringData(BusControl.BUS_ROUTE.PC_PC);
        }
        else
        {
            busSystem.StartTransferringData(register.RouteToPC);
            yield return(new WaitForSeconds(clock.GetSpeed()));

            PC.Write(register.ReadString());
            busSystem.StopTransferringData(register.RouteToPC);
        }
    }