public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable) { if (info.name == "la") { if (!dataTable.ContainsKey(pseudoLabel)) { throw new ArgumentException("label not found! " + ToString()); } regs.Registers[rt] = dataTable[pseudoLabel]; } else if (info.name == "lw") { if (pseudoLabel != "") { if (!dataTable.ContainsKey(pseudoLabel)) { throw new ArgumentException("label not found! " + ToString()); } regs.Registers[rt] = memory.CmdLoadWord(dataTable[pseudoLabel]); } else { regs.Registers[rt] = memory.CmdLoadWord(regs.Registers[rs] + immediate); } } else if (info.name == "sw") { memory.CmdSaveWord(regs.Registers[rs] + immediate, regs.Registers[rt]); } }
public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable) { switch (info.name) { case "slt": regs.Registers[rd] = regs.Registers[rs] < regs.Registers[rt] ? 1 : 0; break; } }
public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable) { switch (info.name) { case "addi": regs.Registers[rt] = regs.Registers[rs] + immediate; break; } }
public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable) { if (!linkerTable.ContainsKey(jumpLabel)) { throw new ArgumentException("jump label not found! " + ToString()); } regs.PC = linkerTable[jumpLabel]; }
public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable) { if (!linkerTable.ContainsKey(bLabel)) { throw new ArgumentException("branch label not found! " + ToString()); } if (info.name == "beq" && regs.Registers[rs] == regs.Registers[rt]) { regs.PC = linkerTable[bLabel]; } if (info.name == "bne" && regs.Registers[rs] != regs.Registers[rt]) { regs.PC = linkerTable[bLabel]; } }
public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable) { switch (info.name) { case "sll": regs.Registers[rd] = (int)(((uint)regs.Registers[rt]) << shift); break; case "srl": regs.Registers[rd] = (int)(((uint)regs.Registers[rt]) >> shift); break; case "sra": regs.Registers[rd] = regs.Registers[rt] >> shift; break; } }
public void execute(MipsMemory memory, Dictionary <string, int> dataTable) { string[] split = args.Split(' '); int pointer = 0; switch (instruction) { case ".word": int[] intArray = new int[split.Length]; for (int i = 0; i < split.Length; i++) { intArray[i] = Convert.ToInt32(split[i]); } pointer = memory.SaveWords(intArray); break; case ".half": short[] halfArray = new short[split.Length]; for (int i = 0; i < split.Length; i++) { halfArray[i] = Convert.ToInt16(split[i]); } pointer = memory.SaveHalfs(halfArray); break; case ".byte": byte[] byteArray = new byte[split.Length]; for (int i = 0; i < split.Length; i++) { byteArray[i] = Convert.ToByte(split[i]); } pointer = memory.SaveBytes(byteArray); break; case ".space": int count = Convert.ToInt32(split[0]); pointer = memory.ReserveBytes(count); break; } if (label != "") { dataTable.Add(label, pointer); } }
public override void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable) { throw new NotImplementedException(); }
public abstract void execute(MipsMemory memory, MipsRegisters regs, Dictionary <string, int> linkerTable, Dictionary <string, int> dataTable);