CInstruction Class Reference

#include <cinstruction.h>

Inheritance diagram for CInstruction:

CInstructionAdd CInstructionDec CInstructionDiv CInstructionInc CInstructionJumpA CInstructionJumpS CInstructionJumpZ CInstructionLabel CInstructionLoad CInstructionMul CInstructionStore CInstructionSub CInstructionTest CInstructionWrite

List of all members.

Public Member Functions

 CInstruction (std::string name)
 Default ctor.
virtual ~CInstruction ()
 Default dtor.
virtual bool operator== (std::string &name)
 implementation of operator ==
virtual CInstructionoperator() (CCPU *cpu)
 implementation of operator (CCPU)
virtual const
std::string & 
getName ()
 returns instruction name
virtual std::ostream & dump (std::ostream &stream)
 dumps information about instruction to outputstream
virtual const unsigned parseRegister (const std::string &str)
 parses register syntax Rx (e.g. "R1")
virtual void checkRegister (CCPU *cpu, const unsigned regidx)
 performs a register boundary check does the register exist in cpu?
virtual CInstructionfactory ()=0
 creates a new instance of this instruction
virtual void compile (std::list< std::string > &params)=0
 parses instruction parameters and prepares the instruction for executing
virtual void execute (CCPU *cpu)=0
 executes the instruction

Protected Attributes

std::string m_name

Friends

std::ostream & operator<< (std::ostream &stream, CInstruction &instr)
 Shift/output operator for outputstream.


Detailed Description

Abstract class for displays

Constructor & Destructor Documentation

CInstruction::CInstruction ( std::string  name  )  [inline]

Default ctor.

Methodname:
CInstruction
Parameters:
name name of instruction
Returns:
-
Global variables used:
none
Exceptions:
none 
Conditions:
none

virtual CInstruction::~CInstruction (  )  [inline, virtual]

Default dtor.

Methodname:
~CInstruction
Parameters:
- 
Returns:
-
Global variables used:
none
Exceptions:
none 
Conditions:
none


Member Function Documentation

virtual bool CInstruction::operator== ( std::string &  name  )  [inline, virtual]

implementation of operator ==

Methodname:
operator==
Parameters:
name reference to std::string
Returns:
true if instructionname is name
Global variables used:
none
Exceptions:
none 
Conditions:
none

virtual CInstruction& CInstruction::operator() ( CCPU cpu  )  [inline, virtual]

implementation of operator (CCPU)

Methodname:
operator()
Parameters:
cpu pointer to cpu
Returns:
-
Global variables used:
none
Exceptions:
std::runtime_error 
Conditions:
none

virtual const std::string& CInstruction::getName (  )  [inline, virtual]

returns instruction name

Methodname:
getName
Parameters:
- 
Returns:
name of instruction
Global variables used:
none
Exceptions:
none 
Conditions:
none

virtual std::ostream& CInstruction::dump ( std::ostream &  stream  )  [inline, virtual]

dumps information about instruction to outputstream

Methodname:
dump
Parameters:
stream outputstream
Returns:
reference to outputstream
Global variables used:
none
Exceptions:
none 
Conditions:
none

const unsigned CInstruction::parseRegister ( const std::string &  str  )  [virtual]

parses register syntax Rx (e.g. "R1")

Methodname:
parseRegister
Parameters:
str register in assembler syntax
Returns:
registernumber
Global variables used:
none
Exceptions:
std::runtime_error 
Conditions:
none

void CInstruction::checkRegister ( CCPU cpu,
const unsigned  regidx 
) [inline, virtual]

performs a register boundary check does the register exist in cpu?

Methodname:
checkRegister
Parameters:
cpu pointer to cpu
regidx registernumber
Returns:
-
Global variables used:
none
Exceptions:
std::runtime_error 
Conditions:
none

virtual CInstruction* CInstruction::factory (  )  [pure virtual]

creates a new instance of this instruction

Methodname:
factory
Parameters:
- 
Returns:
new instruction instance
Global variables used:
none
Exceptions:
none 
Conditions:
none

Implemented in CInstructionInc, CInstructionDec, CInstructionAdd, CInstructionSub, CInstructionMul, CInstructionDiv, CInstructionLoad, CInstructionStore, CInstructionTest, CInstructionLabel, CInstructionJumpA, CInstructionJumpZ, CInstructionJumpS, and CInstructionWrite.

virtual void CInstruction::compile ( std::list< std::string > &  params  )  [pure virtual]

parses instruction parameters and prepares the instruction for executing

Methodname:
compile
Parameters:
params list of parameters of this instruction
Returns:
-
Global variables used:
none
Exceptions:
std::runtime_error 
Conditions:
none

Implemented in CInstructionInc, CInstructionDec, CInstructionAdd, CInstructionSub, CInstructionMul, CInstructionDiv, CInstructionLoad, CInstructionStore, CInstructionTest, CInstructionLabel, CInstructionJumpA, CInstructionJumpZ, CInstructionJumpS, and CInstructionWrite.

virtual void CInstruction::execute ( CCPU cpu  )  [pure virtual]

executes the instruction

Methodname:
execute
Parameters:
cpu pointer to cpu
Returns:
-
Global variables used:
none
Exceptions:
std::runtime_error 
Conditions:
none

Implemented in CInstructionInc, CInstructionDec, CInstructionAdd, CInstructionSub, CInstructionMul, CInstructionDiv, CInstructionLoad, CInstructionStore, CInstructionTest, CInstructionLabel, CInstructionJumpA, CInstructionJumpZ, CInstructionJumpS, and CInstructionWrite.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
CInstruction instr 
) [friend]

Shift/output operator for outputstream.

Methodname:
operator<<
Parameters:
stream reference to outputstream
instr object which will be printed to stream
Returns:
reference to outputstream
Global variables used:
none
Exceptions:
none 
Conditions:
none


Member Data Documentation

std::string CInstruction::m_name [protected]

name of instruction


The documentation for this class was generated from the following files:
Generated on Thu May 14 18:19:17 2009 for mycpu by  doxygen 1.5.3