CInstruction< T > Class Template Reference

#include <cinstruction.h>

Inheritance diagram for CInstruction< T >:

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

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< T > *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< T > *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< T > *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

template<class T>
class CInstruction< T >

Abstract class for instructions

Constructor & Destructor Documentation

template<class T>
CInstruction< T >::CInstruction ( std::string  name  )  [inline]

Default ctor.

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

template<class T>
virtual CInstruction< T >::~CInstruction (  )  [inline, virtual]

Default dtor.

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


Member Function Documentation

template<class T>
virtual bool CInstruction< T >::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 
Precondition:
none
Postcondition:
none

template<class T>
virtual CInstruction& CInstruction< T >::operator() ( CCPU< T > *  cpu  )  [inline, virtual]

implementation of operator (CCPU)

Methodname:
operator()
Parameters:
cpu pointer to cpu
Returns:
-
Global variables used:
none
Exceptions:
CInstructionError 
Precondition:
none
Postcondition:
none

template<class T>
virtual const std::string& CInstruction< T >::getName (  )  [inline, virtual]

returns instruction name

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

template<class T>
virtual std::ostream& CInstruction< T >::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 
Precondition:
none
Postcondition:
none

template<class T>
const unsigned CInstruction< T >::parseRegister ( const std::string &  str  )  [inline, virtual]

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

Methodname:
parseRegister
Parameters:
str register in assembler syntax
Returns:
registernumber
Global variables used:
none
Exceptions:
CInstructionError 
Precondition:
str != NULL
Postcondition:
none

template<class T>
void CInstruction< T >::checkRegister ( CCPU< T > *  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:
CInstructionError 
Precondition:
none
Postcondition:
none

template<class T>
virtual CInstruction* CInstruction< T >::factory (  )  [pure virtual]

creates a new instance of this instruction

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

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

template<class T>
virtual void CInstruction< T >::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:
CInstructionError 
Precondition:
none
Postcondition:
none

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

template<class T>
virtual void CInstruction< T >::execute ( CCPU< T > *  cpu  )  [pure virtual]

executes the instruction

Methodname:
execute
Parameters:
cpu pointer to cpu
Returns:
-
Global variables used:
none
Exceptions:
CInstructionError 
Precondition:
cpu valid (memory, program, registers valid)
Postcondition:
none

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


Friends And Related Function Documentation

template<class T>
std::ostream& operator<< ( std::ostream &  stream,
CInstruction< T > &  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 
Precondition:
none
Postcondition:
none


Member Data Documentation

template<class T>
std::string CInstruction< T >::m_name [protected]

name of instruction


The documentation for this class was generated from the following file:
Generated on Sat May 30 16:32:35 2009 for mycpu by  doxygen 1.5.3