OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
InfoRegistersCommand Class Reference
Inheritance diagram for InfoRegistersCommand:
Inheritance graph
Collaboration diagram for InfoRegistersCommand:
Collaboration graph

Public Member Functions

 InfoRegistersCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~InfoRegistersCommand ()
 
virtual bool execute (const std::vector< DataObject > &arguments)
 
- Public Member Functions inherited from SimControlLanguageSubCommand
 SimControlLanguageSubCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~SimControlLanguageSubCommand ()
 
virtual SimControlLanguageCommandparent ()
 

Static Public Member Functions

static std::string registerDescription (const std::string &regName, const SimValue &value)
 

Detailed Description

Implementation of "info registers".

Definition at line 92 of file InfoCommand.cc.

Constructor & Destructor Documentation

◆ InfoRegistersCommand()

InfoRegistersCommand::InfoRegistersCommand ( SimControlLanguageCommand parentCommand)
inline

Constructor.

Definition at line 98 of file InfoCommand.cc.

◆ ~InfoRegistersCommand()

virtual InfoRegistersCommand::~InfoRegistersCommand ( )
inlinevirtual

Destructor.

Definition at line 105 of file InfoCommand.cc.

105 {
106 }

Member Function Documentation

◆ execute()

virtual bool InfoRegistersCommand::execute ( const std::vector< DataObject > &  arguments)
inlinevirtual

Executes the "info registers" command.

"info registers regfile regname" prints the value of register regname in register file regfile, where regfile is the name of a register file of the target processor, and regname is the name of a register that belongs to the specified register file. If regname is omitted, values of all registers of the specified register file are displayed.

Parameters
argumentsArguments to the command, including "info registers".
Returns
true in case execution was successful.

Implements SimControlLanguageSubCommand.

Definition at line 120 of file InfoCommand.cc.

120 {
121
122 if (!parent().checkProgramLoaded()) {
123 return false;
124 }
125
126 const int argumentCount = arguments.size() - 2;
127 if (!parent().checkArgumentCount(argumentCount, 1, 2)) {
128 return false;
129 }
130
131 std::string registerFile = "";
132 std::string registerName = "";
133 std::string registerString = "";
134 int registerIndex = -1;
135
136 if (argumentCount == 1) {
137 // 'ra' is treated as a special case
138 if (StringTools::ciEqual(registerString, "ra")) {
139 StateData& data =
140 parent().simulatorFrontend().state(registerString);
141
143 registerDescription(registerString, data.value()));
144 return true;
145 }
146
147 registerFile = arguments[2].stringValue();
148
149 try {
151 parent().simulatorFrontend().registerFileValue(registerFile));
152 } catch (const InstanceNotFound&) {
156 return false;
157 }
158 return true;
159
160 } else if (argumentCount == 2) {
161 // prints out the register in the given register file
162 if (!parent().checkPositiveIntegerArgument(arguments[3])) {
163 return false;
164 }
165 registerFile = arguments[2].stringValue();
166 registerIndex = arguments[3].integerValue();
167 registerName =
168 registerFile + "." + Conversion::toString(registerIndex);
169 } else {
170 abortWithError("Illegal count of arguments.");
171 }
172
173 // print a single register value
174 try {
176 parent().simulatorFrontend().registerFileValue(
177 registerFile, registerIndex));
178
179 return true;
180 } catch (const InstanceNotFound&) {
184 return false;
185 }
186 return true;
187 }
#define abortWithError(message)
static std::string toString(const T &source)
ScriptInterpreter * interpreter() const
static std::string registerDescription(const std::string &regName, const SimValue &value)
virtual const SimValue & value() const =0
virtual void setError(bool state)
virtual void setResult(DataObject *result)
virtual SimControlLanguageCommand & parent()
StateData & state(std::string searchString)
static SimulatorTextGenerator & textGenerator()
static bool ciEqual(const std::string &a, const std::string &b)

References abortWithError, StringTools::ciEqual(), CustomCommand::interpreter(), SimControlLanguageSubCommand::parent(), registerDescription(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), SimControlLanguageCommand::simulatorFrontend(), SimulatorFrontend::state(), SimulatorToolbox::textGenerator(), Conversion::toString(), Texts::TXT_REGISTER_NOT_FOUND, and ReadableState::value().

Here is the call graph for this function:

◆ registerDescription()

static std::string InfoRegistersCommand::registerDescription ( const std::string &  regName,
const SimValue value 
)
inlinestatic

Helper function to get register description in correct format.

Parameters
regNameThe name of the register to print.
valueThe current value of the register.

Definition at line 195 of file InfoCommand.cc.

197 {
198 return regName + " " + value.hexValue() + " " +
200 }
TCEString hexValue(bool noHexIdentifier=false) const
Definition SimValue.cc:1150
SLongWord sLongWordValue() const
Definition SimValue.cc:997

References SimValue::hexValue(), SimValue::sLongWordValue(), and Conversion::toString().

Referenced by execute(), InfoImmediatesCommand::execute(), and InfoPortsCommand::execute().

Here is the call graph for this function:

The documentation for this class was generated from the following file: