Exemplo n.º 1
0
    //MICRO_INSTRUCTIONS*****************************************/

    /**
     * @brief Executes an instruction.
     * @param id - the ID of the instruction to be executed.
     */
    public IEnumerator ExecuteInstrucion(int id)
    {
        switch (id)
        {
        case (0x00):
            ALU.SetAdditionCircuitry();
            yield return(Instruction_IMMEDIATE_COMPUTE(GPA));

            break;

        case (0x01):
            ALU.SetAdditionCircuitry();
            yield return(Instruction_IMMEDIATE_COMPUTE(GPB));

            break;

        case (0x02):
            ALU.SetAdditionCircuitry();
            yield return(Instruction_DIRECT_COMPUTE(GPA));

            break;

        case (0x03):
            ALU.SetAdditionCircuitry();
            yield return(Instruction_DIRECT_COMPUTE(GPB));

            break;

        case (0x04):
            ALU.SetAdditionCircuitry();
            yield return(Instruction_COMPUTE(GPA, GPB));

            break;

        case (0x05):
            ALU.SetAdditionCircuitry();
            yield return(Instruction_COMPUTE(GPB, GPA));

            break;

        case (0x06):
            ALU.SetSubtractionCircuitry();
            yield return(Instruction_IMMEDIATE_COMPUTE(GPA));

            break;

        case (0x07):
            ALU.SetSubtractionCircuitry();
            yield return(Instruction_IMMEDIATE_COMPUTE(GPB));

            break;

        case (0x08):
            ALU.SetSubtractionCircuitry();
            yield return(Instruction_DIRECT_COMPUTE(GPA));

            break;

        case (0x09):
            ALU.SetSubtractionCircuitry();
            yield return(Instruction_DIRECT_COMPUTE(GPB));

            break;

        case (0x0A):
            ALU.SetSubtractionCircuitry();
            yield return(Instruction_COMPUTE(GPA, GPB));

            break;

        case (0x0B):
            ALU.SetSubtractionCircuitry();
            yield return(Instruction_COMPUTE(GPB, GPA));

            break;

        case (0x0C):
            yield return(Instruction_IMMEDIATE_COMPARE(GPA));

            break;

        case (0x0D):
            yield return(Instruction_IMMEDIATE_COMPARE(GPB));

            break;

        case (0x0E):
            yield return(Instruction_DIRECT_COMPARE(GPA));

            break;

        case (0x0F):
            yield return(Instruction_DIRECT_COMPARE(GPB));

            break;

        case (0x10):
            yield return(Instruction_COMPARE(GPA, GPB));

            break;

        case (0x11):
            yield return(Instruction_COMPARE(GPB, GPA));

            break;

        case (0x12):
            yield return(ReadIROperand(GPA));

            break;

        case (0x13):
            yield return(ReadIROperand(GPB));

            break;

        case (0x14):
            yield return(MemoryDirectFetch());

            yield return(WriteToGPA(MDR));

            break;

        case (0x15):
            yield return(MemoryDirectFetch());

            yield return(WriteToGPB(MDR));

            break;

        case (0x16):
            yield return(WriteToGPA(GPB));

            break;

        case (0x17):
            yield return(WriteToGPB(GPA));

            break;

        case (0x18):
            yield return(Instruction_moveToMemory_DIRECT(GPA));

            break;

        case (0x19):
            yield return(Instruction_moveToMemory_DIRECT(GPB));

            break;

        case (0x1A):
            yield return(Instruction_moveToMemory_INDIRECT(GPA));

            break;

        case (0x1B):
            yield return(Instruction_moveToMemory_INDIRECT(GPB));

            break;

        case (0x1C):
            yield return(ReadIROperand(PC));

            break;

        case (0x1D):
            yield return(Instruction_DIRECT_jump());

            break;

        case (0x1E):
            yield return(Instruction_IMMEDIATE_branchOnFlag(ProcessStatusRegister.FLAGS.CARRY, true));

            break;

        case (0x1F):
            yield return(Instruction_IMMEDIATE_branchOnFlag(ProcessStatusRegister.FLAGS.CARRY, false));

            break;

        case (0x20):
            yield return(Instruction_DIRECT_branchOnFlag(ProcessStatusRegister.FLAGS.CARRY, true));

            break;

        case (0x21):
            yield return(Instruction_DIRECT_branchOnFlag(ProcessStatusRegister.FLAGS.CARRY, false));

            break;

        case (0x22):
            yield return(Instruction_IMMEDIATE_branchOnFlag(ProcessStatusRegister.FLAGS.NEGATIVE, true));

            break;

        case (0x23):
            yield return(Instruction_IMMEDIATE_branchOnFlag(ProcessStatusRegister.FLAGS.NEGATIVE, false));

            break;

        case (0x24):
            yield return(Instruction_DIRECT_branchOnFlag(ProcessStatusRegister.FLAGS.NEGATIVE, true));

            break;

        case (0x25):
            yield return(Instruction_DIRECT_branchOnFlag(ProcessStatusRegister.FLAGS.NEGATIVE, false));

            break;

        case (0x26):
            yield return(Instruction_IMMEDIATE_branchOnFlag(ProcessStatusRegister.FLAGS.ZERO, true));

            break;

        case (0x27):
            yield return(Instruction_IMMEDIATE_branchOnFlag(ProcessStatusRegister.FLAGS.ZERO, false));

            break;

        case (0x28):
            yield return(Instruction_DIRECT_branchOnFlag(ProcessStatusRegister.FLAGS.ZERO, true));

            break;

        case (0x29):
            yield return(Instruction_DIRECT_branchOnFlag(ProcessStatusRegister.FLAGS.ZERO, false));

            break;

        case (0x2A):
            yield return(Instruction_IMMEDIATE_branchOnFlag(ProcessStatusRegister.FLAGS.OVERFLOW, true));

            break;

        case (0x2B):
            yield return(Instruction_IMMEDIATE_branchOnFlag(ProcessStatusRegister.FLAGS.OVERFLOW, false));

            break;

        case (0x2C):
            yield return(Instruction_DIRECT_branchOnFlag(ProcessStatusRegister.FLAGS.OVERFLOW, true));

            break;

        case (0x2D):
            yield return(Instruction_DIRECT_branchOnFlag(ProcessStatusRegister.FLAGS.OVERFLOW, false));

            break;
        }
    }