From 89e202f49b9857dcd3627fbc4e0262125d729bbc Mon Sep 17 00:00:00 2001 From: manuel Date: Wed, 13 May 2009 04:09:39 +0200 Subject: adding all instructions and displays --- ue3/mycpu/cinstruction.h | 133 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 118 insertions(+), 15 deletions(-) (limited to 'ue3/mycpu/cinstruction.h') diff --git a/ue3/mycpu/cinstruction.h b/ue3/mycpu/cinstruction.h index b16c067..57fcff1 100644 --- a/ue3/mycpu/cinstruction.h +++ b/ue3/mycpu/cinstruction.h @@ -10,9 +10,8 @@ #include #include -//#include "ccpu.h" -/* declare CCPU */ +/* forward declare CCPU */ class CCPU; /** @@ -26,7 +25,7 @@ class CInstruction /** * @method CInstruction * @brief Default ctor - * @param - + * @param name name of instruction * @return - * @globalvars none * @exception none @@ -34,7 +33,7 @@ class CInstruction */ CInstruction(std::string name) : m_name(name) - {}; + {} /** * @method ~CInstruction @@ -46,46 +45,150 @@ class CInstruction * @conditions none */ virtual ~CInstruction() - {}; + {} - /* TODO */ + /** + * @method operator== + * @brief implementation of operator == + * @param reference to std::string + * @return true if instructionname is name + * @globalvars none + * @exception none + * @conditions none + */ virtual bool operator==(std::string& name) { return name == m_name; } - /* TODO */ + /** + * @method getName + * @brief returns instruction name + * @param - + * @return name of instruction + * @globalvars none + * @exception none + * @conditions none + */ virtual const std::string& getName() { return m_name; } - /* TODO */ + /** + * @method isLabel + * @brief returns true if the instruction defines a label + * @param - + * @return true if the instruction defines a label + * @globalvars none + * @exception none + * @conditions none + */ + virtual const bool isLabel() + { + return false; + } + + /** + * @method getLabelName + * @brief returns labelname if the instruction defines a label + * @param - + * @return labelname if the instruction defines a label + * @globalvars none + * @exception none + * @conditions none + */ + virtual const std::string getLabelName() + { + return ""; + } + + /** + * @method dump + * @brief dumps information about instruction to outputstream + * @param stream outputstream + * @return reference to outputstream + * @globalvars none + * @exception none + * @conditions none + */ virtual std::ostream& dump(std::ostream& stream) { stream << m_name; return stream; } - /* TODO */ + /** + * @method operator<< + * @brief Shift/output operator for outputstream + * @param stream reference to outputstream + * @param cdat object which will be printed to stream + * @return reference to outputstream + * @globalvars none + * @exception none + * @conditions none + */ friend std::ostream& operator<<(std::ostream& stream, CInstruction& instr) { return instr.dump(stream); } - /* TODO */ + /** + * @method parseRegister + * @brief parses register syntax Rx (e.g. "R1") + * @param str register in assembler syntax + * @return registernumber + * @globalvars none + * @exception runtime_error + * @conditions none + */ virtual const unsigned parseRegister(const std::string& str); - /* TODO */ - virtual void checkRegister(CCPU *cpu, unsigned regidx); + /** + * @method checkRegister + * @brief performs a register boundary check + * does the register exist in cpu? + * @param cpu pointer to cpu + * @param regidx registernumber + * @return - + * @globalvars none + * @exception runtime_error + * @conditions none + */ + virtual void checkRegister(CCPU *cpu, const unsigned regidx); - /* TODO */ + /** + * @method factory + * @brief creates a new instance of this instruction + * @param - + * @return new instruction instance + * @globalvars none + * @exception none + * @conditions none + */ virtual CInstruction *factory() = 0; - /* TODO */ + /** + * @method compile + * @brief parses instruction parameters and prepares the + * instruction for executing + * @param params list of parameters of this instruction + * @return - + * @globalvars none + * @exception runtime_error + * @conditions none + */ virtual void compile(std::list& params) = 0; - /* TODO */ + /** + * @method execute + * @brief executes the instruction + * @param cpu pointer to cpu + * @return - + * @globalvars none + * @exception runtime_error + * @conditions none + */ virtual void execute(CCPU *cpu) = 0; protected: -- cgit v1.2.3