Exemple #1
0
 private void executeBne(ref MachineCode machineCodeAnalysis)
 {
     incrementPC();
     if (machineCodeAnalysis.rs != machineCodeAnalysis.rt)
     {
         updatePC(centralCtrlData.registerPC + (machineCodeAnalysis.imme & 0xFFFF));
     }
 }
Exemple #2
0
        private void executeLbu(ref MachineCode machineCodeAnalysis)
        {
            uint byteValue = getWordMemoryValue(getRegisterValue(machineCodeAnalysis.rs) + machineCodeAnalysis.imme);

            byteValue = (byteValue & 0xFF000000) >> 24;
            setRegisterValue(machineCodeAnalysis.rt, byteValue);
            incrementPC();
        }
Exemple #3
0
 private void executeBlez(ref MachineCode machineCodeAnalysis)
 {
     incrementPC();
     if ((int)machineCodeAnalysis.rs <= 0)
     {
         updatePC(centralCtrlData.registerPC + (machineCodeAnalysis.imme & 0xFFFF));
     }
 }
Exemple #4
0
        private void executeLhu(ref MachineCode machineCodeAnalysis)
        {
            uint halfWordValue = getWordMemoryValue(getRegisterValue(machineCodeAnalysis.rs) + machineCodeAnalysis.imme);

            halfWordValue = (halfWordValue & 0xFFFF0000) >> 16;
            setRegisterValue(machineCodeAnalysis.rt, halfWordValue);
            incrementPC();
        }
Exemple #5
0
 private void excuteBreak(ref MachineCode machineCodeAnalysis)
 {
 }
Exemple #6
0
 private void executeJ(ref MachineCode machineCodeAnalysis)
 {
     updatePC((((centralCtrlData.registerPC << 2) & 0xF0000000) | (machineCodeAnalysis.target << 2)) >> 2);
 }
Exemple #7
0
 private void executeSwc1(ref MachineCode machineCodeAnalysis)
 {
 }
Exemple #8
0
 private void executeSltiu(ref MachineCode machineCodeAnalysis)
 {
     setRegisterValue(machineCodeAnalysis.rt, (getRegisterValue(machineCodeAnalysis.rs) < machineCodeAnalysis.imme ? (uint)1 : (uint)0));
     incrementPC();
 }
Exemple #9
0
 private void executeLui(ref MachineCode machineCodeAnalysis)
 {
     setRegisterValue(machineCodeAnalysis.rt, (machineCodeAnalysis.imme & 0xFFFF) << 16);
     incrementPC();
 }
Exemple #10
0
 private void excuteSltu(ref MachineCode machineCodeAnalysis)
 {
     setRegisterValue(machineCodeAnalysis.rd, (getRegisterValue(machineCodeAnalysis.rs) < getRegisterValue(machineCodeAnalysis.rt) ? (uint)1 : (uint)0));
     incrementPC();
 }
Exemple #11
0
 private void excuteSll(ref MachineCode machineCodeAnalysis)
 {
     setRegisterValue(machineCodeAnalysis.rd, getRegisterValue(machineCodeAnalysis.rt) << (int)machineCodeAnalysis.shamt);
     incrementPC();
 }
Exemple #12
0
 private void excuteMultu(ref MachineCode machineCodeAnalysis)
 {
 }
Exemple #13
0
 private void excuteMtlo(ref MachineCode machineCodeAnalysis)
 {
 }
Exemple #14
0
 private void excuteJr(ref MachineCode machineCodeAnalysis)
 {
     updatePC(getRegisterValue(machineCodeAnalysis.rs));
 }
Exemple #15
0
 private void excuteJalr(ref MachineCode machineCodeAnalysis)
 {
     setRegisterValue(machineCodeAnalysis.rd, centralCtrlData.registerPC + 1);
     updatePC(getRegisterValue(machineCodeAnalysis.rs));
 }
Exemple #16
0
 private void excuteDivu(ref MachineCode machineCodeAnalysis)
 {
 }
Exemple #17
0
 private void excuteSra(ref MachineCode machineCodeAnalysis)
 {
     setRegisterValue(machineCodeAnalysis.rd, (uint)((int)getRegisterValue(machineCodeAnalysis.rt) >> (int)machineCodeAnalysis.shamt));
     incrementPC();
 }
Exemple #18
0
 private void excuteSrlv(ref MachineCode machineCodeAnalysis)
 {
     setRegisterValue(machineCodeAnalysis.rd, getRegisterValue(machineCodeAnalysis.rt) >> (int)getRegisterValue(machineCodeAnalysis.rs));
     incrementPC();
 }
Exemple #19
0
 private void executeSb(ref MachineCode machineCodeAnalysis)
 {
     setByteMemoryValue(getRegisterValue(machineCodeAnalysis.rs) + machineCodeAnalysis.imme, getRegisterValue(machineCodeAnalysis.rt) & 0xFF);
     incrementPC();
 }
Exemple #20
0
 private void excuteSyscall(ref MachineCode machineCodeAnalysis)
 {
 }
Exemple #21
0
 private void executeSw(ref MachineCode machineCodeAnalysis)
 {
     setWordMemoryValue(getRegisterValue(machineCodeAnalysis.rs) + machineCodeAnalysis.imme, getRegisterValue(machineCodeAnalysis.rt));
     incrementPC();
 }
Exemple #22
0
 private void excuteXor(ref MachineCode machineCodeAnalysis)
 {
     setRegisterValue(machineCodeAnalysis.rd, getRegisterValue(machineCodeAnalysis.rs) ^ getRegisterValue(machineCodeAnalysis.rt));
     incrementPC();
 }
Exemple #23
0
 private void executeXori(ref MachineCode machineCodeAnalysis)
 {
     setRegisterValue(machineCodeAnalysis.rd, getRegisterValue(machineCodeAnalysis.rs) ^ (machineCodeAnalysis.imme & 0xFFFF));
     incrementPC();
 }
Exemple #24
0
 private void executeAddiu(ref MachineCode machineCodeAnalysis)
 {
     setRegisterValue(machineCodeAnalysis.rt, getRegisterValue(machineCodeAnalysis.rs) + machineCodeAnalysis.imme);
     incrementPC();
 }
Exemple #25
0
 private void executeJal(ref MachineCode machineCodeAnalysis)
 {
     setRegisterValue(machineCodeAnalysis.rd, centralCtrlData.registerPC + 1);
     updatePC((((centralCtrlData.registerPC << 2) & 0xF0000000) | (machineCodeAnalysis.target << 2)) >> 2);
 }
Exemple #26
0
        public void excuteMachineCode(uint machineCode)
        {
            MachineCode machineCodeAnalysis = new MachineCode(machineCode);

            switch (machineCodeAnalysis.opcode)
            {
            case 0x0:
                switch (machineCodeAnalysis.func)
                {
                case 0x20: excuteAdd(ref machineCodeAnalysis); break;

                case 0x21: excuteAddu(ref machineCodeAnalysis); break;

                case 0x24: excuteAnd(ref machineCodeAnalysis); break;

                case 0x0D: excuteBreak(ref machineCodeAnalysis); break;

                case 0x1A: excuteDiv(ref machineCodeAnalysis); break;

                case 0x1B: excuteDivu(ref machineCodeAnalysis); break;

                case 0x09: excuteJalr(ref machineCodeAnalysis); break;

                case 0x08: excuteJr(ref machineCodeAnalysis); break;

                case 0x10: excuteMfhi(ref machineCodeAnalysis); break;

                case 0x12: excuteMflo(ref machineCodeAnalysis); break;

                case 0x11: excuteMthi(ref machineCodeAnalysis); break;

                case 0x13: excuteMtlo(ref machineCodeAnalysis); break;

                case 0x18: excuteMult(ref machineCodeAnalysis); break;

                case 0x19: excuteMultu(ref machineCodeAnalysis); break;

                case 0x27: excuteNor(ref machineCodeAnalysis); break;

                case 0x25: excuteOr(ref machineCodeAnalysis); break;

                case 0x00: excuteSll(ref machineCodeAnalysis); break;

                case 0x04: excuteSllv(ref machineCodeAnalysis); break;

                case 0x2A: excuteSlt(ref machineCodeAnalysis); break;

                case 0x2B: excuteSltu(ref machineCodeAnalysis); break;

                case 0x03: excuteSra(ref machineCodeAnalysis); break;

                case 0x07: excuteSrav(ref machineCodeAnalysis); break;

                case 0x02: excuteSrl(ref machineCodeAnalysis); break;

                case 0x06: excuteSrlv(ref machineCodeAnalysis); break;

                case 0x22: excuteSub(ref machineCodeAnalysis); break;

                case 0x23: excuteSubu(ref machineCodeAnalysis); break;

                case 0x0C: excuteSyscall(ref machineCodeAnalysis); break;

                case 0x26: excuteXor(ref machineCodeAnalysis); break;
                }
                break;

            case 0x08: executeAddi(ref machineCodeAnalysis); break;

            case 0x09: executeAddiu(ref machineCodeAnalysis); break;

            case 0x0C: executeAndi(ref machineCodeAnalysis); break;

            case 0x04: executeBeq(ref machineCodeAnalysis); break;

            case 0x01:
                if (machineCodeAnalysis.rt == 0x1)
                {
                    executeBgez(ref machineCodeAnalysis);
                }
                else if (machineCodeAnalysis.rt == 0x0)
                {
                    executeBltz(ref machineCodeAnalysis);
                }
                break;

            case 0x07: executeBgtz(ref machineCodeAnalysis); break;

            case 0x06: executeBlez(ref machineCodeAnalysis); break;

            case 0x05: executeBne(ref machineCodeAnalysis); break;

            case 0x20: executeLb(ref machineCodeAnalysis); break;

            case 0x24: executeLbu(ref machineCodeAnalysis); break;

            case 0x21: executeLh(ref machineCodeAnalysis); break;

            case 0x25: executeLhu(ref machineCodeAnalysis); break;

            case 0x0F: executeLui(ref machineCodeAnalysis); break;

            case 0x23: executeLw(ref machineCodeAnalysis); break;

            case 0x31: executeLwc1(ref machineCodeAnalysis); break;

            case 0x0D: executeOri(ref machineCodeAnalysis); break;

            case 0x28: executeSb(ref machineCodeAnalysis); break;

            case 0x0A: executeSlti(ref machineCodeAnalysis); break;

            case 0x0B: executeSltiu(ref machineCodeAnalysis); break;

            case 0x29: executeSh(ref machineCodeAnalysis); break;

            case 0x2B: executeSw(ref machineCodeAnalysis); break;

            case 0x39: executeSwc1(ref machineCodeAnalysis); break;

            case 0x0E: executeXori(ref machineCodeAnalysis); break;

            case 0x02: executeJ(ref machineCodeAnalysis); break;

            case 0x03: executeJal(ref machineCodeAnalysis); break;

            default: break;
            }
            centralCtrlData.registers[0] = 0x0;
            updateRegisterLabels();
        }