/// <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); }
/// <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 += m_Name + ' '; if (inst.Parameters.Count() != 2) { throw new ArgumentException("U-type instruction expected 2 arguments, received " + inst.Parameters.Count()); } string rd = ReverseRegisterMap.GetStringifiedRegisterValue(inst.Parameters.ElementAt(0)); int immediate = inst.Parameters.ElementAt(1); retStr += rd + ", 0x" + immediate.ToString("X2"); 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; } }
/// <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 += m_Name + ' '; if (inst.Parameters.Count() != 3) { throw new ArgumentException("sb instruction expected 3 arguments, received " + inst.Parameters.Count()); } string rs1 = ReverseRegisterMap.GetStringifiedRegisterValue(inst.Parameters.ElementAt(0)); string rs2 = ReverseRegisterMap.GetStringifiedRegisterValue(inst.Parameters.ElementAt(1)); retStr += rs1 + ", " + rs2 + ", "; int offset = inst.Parameters.ElementAt(2); int address = currPgrmCtr + offset; // see if there's a symbol mapped to it. if (symTable.ContainsSymbol(address)) { Symbol sym = symTable.GetSymbol(address); retStr += sym.LabelName; } else { retStr += "0x" + address.ToString("X2"); } return(retStr); }
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; } }