public void Execute(string[] args) { try { string regName = args[0]; if (IntExtensions.TryParseEx(args[1], out int iValue)) { if (RegisterMap.IsNamedIntegerRegister(regName)) { int regIdx = RegisterMap.GetNumericRegisterValue(regName); m_Registers.UserIntRegisters[regIdx].Value = iValue; m_Terminal.PrintString("\t" + regName + " = " + iValue + '\n'); } else { throw new ParseException(regName + " was not a valid register name."); } } else if (FloatExtensions.TryParseEx(args[1], out float fValue)) { if (RegisterMap.IsNamedFloatingPointRegister(regName)) { int regIdx = RegisterMap.GetNumericFloatingPointRegisterValue(regName); m_Registers.UserFloatingPointRegisters[regIdx].Value = fValue; m_Terminal.PrintString("\t" + regName + " = " + fValue + '\n'); } else { throw new ParseException(regName + " was not a valid register name."); } } else { throw new ParseException(args[1] + " was not a valid 32-bit value"); } } catch (Exception ex) { m_Terminal.PrintString(ex.Message + '\n'); } }
public void Execute(string[] args) { try { string fmtString = args[1]; if (fmtString.Contains("\"")) { fmtString = fmtString.Replace("\"", string.Empty); } fmtString = fmtString.Trim(); int regIdx = -1; string regName = string.Empty; if (RegisterMap.IsNamedIntegerRegister(args[0])) { regIdx = RegisterMap.GetNumericRegisterValue(args[0]); regName = args[0]; m_Terminal.PrintString("\t" + regName + " = " + m_Registers.UserIntRegisters[regIdx].Value.ToString(fmtString) + '\n'); } else if (RegisterMap.IsNamedFloatingPointRegister(args[0])) { regIdx = RegisterMap.GetNumericFloatingPointRegisterValue(args[0]); regName = args[0]; m_Terminal.PrintString("\t" + regName + " = " + m_Registers.UserFloatingPointRegisters[regIdx].Value.ToString(fmtString) + '\n'); } else { throw new ParseException(regIdx + " was not a valid register name."); } } catch (Exception ex) { m_Terminal.PrintString(ex.Message + '\n'); } }