private void executeBne(ref MachineCode machineCodeAnalysis) { incrementPC(); if (machineCodeAnalysis.rs != machineCodeAnalysis.rt) { updatePC(centralCtrlData.registerPC + (machineCodeAnalysis.imme & 0xFFFF)); } }
private void executeLbu(ref MachineCode machineCodeAnalysis) { uint byteValue = getWordMemoryValue(getRegisterValue(machineCodeAnalysis.rs) + machineCodeAnalysis.imme); byteValue = (byteValue & 0xFF000000) >> 24; setRegisterValue(machineCodeAnalysis.rt, byteValue); incrementPC(); }
private void executeBlez(ref MachineCode machineCodeAnalysis) { incrementPC(); if ((int)machineCodeAnalysis.rs <= 0) { updatePC(centralCtrlData.registerPC + (machineCodeAnalysis.imme & 0xFFFF)); } }
private void executeLhu(ref MachineCode machineCodeAnalysis) { uint halfWordValue = getWordMemoryValue(getRegisterValue(machineCodeAnalysis.rs) + machineCodeAnalysis.imme); halfWordValue = (halfWordValue & 0xFFFF0000) >> 16; setRegisterValue(machineCodeAnalysis.rt, halfWordValue); incrementPC(); }
private void excuteBreak(ref MachineCode machineCodeAnalysis) { }
private void executeJ(ref MachineCode machineCodeAnalysis) { updatePC((((centralCtrlData.registerPC << 2) & 0xF0000000) | (machineCodeAnalysis.target << 2)) >> 2); }
private void executeSwc1(ref MachineCode machineCodeAnalysis) { }
private void executeSltiu(ref MachineCode machineCodeAnalysis) { setRegisterValue(machineCodeAnalysis.rt, (getRegisterValue(machineCodeAnalysis.rs) < machineCodeAnalysis.imme ? (uint)1 : (uint)0)); incrementPC(); }
private void executeLui(ref MachineCode machineCodeAnalysis) { setRegisterValue(machineCodeAnalysis.rt, (machineCodeAnalysis.imme & 0xFFFF) << 16); incrementPC(); }
private void excuteSltu(ref MachineCode machineCodeAnalysis) { setRegisterValue(machineCodeAnalysis.rd, (getRegisterValue(machineCodeAnalysis.rs) < getRegisterValue(machineCodeAnalysis.rt) ? (uint)1 : (uint)0)); incrementPC(); }
private void excuteSll(ref MachineCode machineCodeAnalysis) { setRegisterValue(machineCodeAnalysis.rd, getRegisterValue(machineCodeAnalysis.rt) << (int)machineCodeAnalysis.shamt); incrementPC(); }
private void excuteMultu(ref MachineCode machineCodeAnalysis) { }
private void excuteMtlo(ref MachineCode machineCodeAnalysis) { }
private void excuteJr(ref MachineCode machineCodeAnalysis) { updatePC(getRegisterValue(machineCodeAnalysis.rs)); }
private void excuteJalr(ref MachineCode machineCodeAnalysis) { setRegisterValue(machineCodeAnalysis.rd, centralCtrlData.registerPC + 1); updatePC(getRegisterValue(machineCodeAnalysis.rs)); }
private void excuteDivu(ref MachineCode machineCodeAnalysis) { }
private void excuteSra(ref MachineCode machineCodeAnalysis) { setRegisterValue(machineCodeAnalysis.rd, (uint)((int)getRegisterValue(machineCodeAnalysis.rt) >> (int)machineCodeAnalysis.shamt)); incrementPC(); }
private void excuteSrlv(ref MachineCode machineCodeAnalysis) { setRegisterValue(machineCodeAnalysis.rd, getRegisterValue(machineCodeAnalysis.rt) >> (int)getRegisterValue(machineCodeAnalysis.rs)); incrementPC(); }
private void executeSb(ref MachineCode machineCodeAnalysis) { setByteMemoryValue(getRegisterValue(machineCodeAnalysis.rs) + machineCodeAnalysis.imme, getRegisterValue(machineCodeAnalysis.rt) & 0xFF); incrementPC(); }
private void excuteSyscall(ref MachineCode machineCodeAnalysis) { }
private void executeSw(ref MachineCode machineCodeAnalysis) { setWordMemoryValue(getRegisterValue(machineCodeAnalysis.rs) + machineCodeAnalysis.imme, getRegisterValue(machineCodeAnalysis.rt)); incrementPC(); }
private void excuteXor(ref MachineCode machineCodeAnalysis) { setRegisterValue(machineCodeAnalysis.rd, getRegisterValue(machineCodeAnalysis.rs) ^ getRegisterValue(machineCodeAnalysis.rt)); incrementPC(); }
private void executeXori(ref MachineCode machineCodeAnalysis) { setRegisterValue(machineCodeAnalysis.rd, getRegisterValue(machineCodeAnalysis.rs) ^ (machineCodeAnalysis.imme & 0xFFFF)); incrementPC(); }
private void executeAddiu(ref MachineCode machineCodeAnalysis) { setRegisterValue(machineCodeAnalysis.rt, getRegisterValue(machineCodeAnalysis.rs) + machineCodeAnalysis.imme); incrementPC(); }
private void executeJal(ref MachineCode machineCodeAnalysis) { setRegisterValue(machineCodeAnalysis.rd, centralCtrlData.registerPC + 1); updatePC((((centralCtrlData.registerPC << 2) & 0xF0000000) | (machineCodeAnalysis.target << 2)) >> 2); }
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(); }