/// <summary> /// Formats and stringifies an instruction as well as its parameters. /// </summary> /// <param name="currPgrmCtr">The value that the program counter would theoretically be at /// upon encountering this instruction.</param> /// <param name="inst">The disassembled instruction to stringify.</param> /// <param name="symTable">A reverse symbol table used to map addresses back to label names.</param> /// <returns>A string representing the instruction and its parameters that can be written to a text file.</returns> public string GetFormattedInstruction(int currPgrmCtr, DisassembledInstruction inst, ReverseSymbolTable symTable) { string retStr = string.Empty; // first, see if the program counter has a symbol mapped to it. if (symTable.ContainsSymbol(currPgrmCtr)) { Symbol sym = symTable.GetSymbol(currPgrmCtr); retStr += sym.LabelName + ":\t\t"; } else { retStr += "\t\t\t"; } retStr += "flw "; if (inst.Parameters.Count() != 3) { throw new ArgumentException("Floating point I instruction expected 3 arguments, received " + inst.Parameters.Count()); } string rd = ReverseRegisterMap.GetStringifiedFloatingPtRegisterValue(inst.Parameters.ElementAt(0)); string rs1 = ReverseRegisterMap.GetStringifiedRegisterValue(inst.Parameters.ElementAt(1)); int offset = inst.Parameters.ElementAt(2); retStr += rd + ", " + offset + "(" + rs1 + ")"; return(retStr); }
public void Execute(string[] args) { string fmtString = args[0]; if (fmtString.Contains("\"")) { fmtString = fmtString.Replace("\"", string.Empty); } fmtString = fmtString.Trim(); int regItr = 0; foreach (var iRegister in m_Registers.UserIntRegisters) { string regName = ReverseRegisterMap.GetStringifiedRegisterValue(regItr); m_Terminal.PrintString(regName + " (" + regItr + ") = " + iRegister.Value.ToString(fmtString) + '\n'); ++regItr; } regItr = 0; foreach (var fRegister in m_Registers.UserFloatingPointRegisters) { string regName = ReverseRegisterMap.GetStringifiedFloatingPtRegisterValue(regItr); m_Terminal.PrintString(regName + " (" + regItr + ") = " + fRegister.Value.ToString(fmtString) + '\n'); ++regItr; } }
public void Execute(string[] args) { int regItr = 0; foreach (var iRegister in m_RegMgr.UserIntRegisters) { string regName = ReverseRegisterMap.GetStringifiedRegisterValue(regItr); m_Terminal.PrintString(regName + " (" + regItr + ") = " + iRegister.Value.ToString() + '\n'); ++regItr; } regItr = 0; foreach (var fRegister in m_RegMgr.UserFloatingPointRegisters) { string regName = ReverseRegisterMap.GetStringifiedFloatingPtRegisterValue(regItr); m_Terminal.PrintString(regName + " (" + regItr + ") = " + fRegister.Value.ToString("0.0######") + '\n'); ++regItr; } }