Register Class Reference

#include <instruction.h>

List of all members.

Public Types

enum  Type {
  TMR0, OPTION_REG, PCL, STATUS,
  FSR, PORTA, TRISA, PORTB,
  TRISB, EEDATA, EECON1, EEADR,
  EECON2, PCLATH, INTCON, WORKING,
  GPR, none
}
enum  Banks { Bank0 = 1 << 0, Bank1 = 1 << 1 }

Public Member Functions

 Register (Type type=none)
 Register (const QString &name)
 Register (const char *name)
bool operator< (const Register &reg) const
bool operator== (const Register &reg) const
uchar banks () const
bool bankDependent () const
QString name () const
Type type () const
bool affectsExternal () const

Protected Attributes

QString m_name
Type m_type


Detailed Description

Abstraction for a Register - should be used instead of a register name. Contains info like whether or not the adressing of the register depends on the bank selection.

Author:
David Saxton

Definition at line 45 of file instruction.h.


Constructor & Destructor Documentation

Register::Register ( Type  type = none  ) 

Creates a register of the given type, giving it the appropriate name. Note that this constructor should not be used for GPR.

Definition at line 34 of file instruction.cpp.

References m_name, and m_type.

Referenced by Register().

Register::Register ( const QString &  name  ) 

Construct a Register with the given name. If the name is not recognized, then it is assumed to be a GPR register.

Definition at line 95 of file instruction.cpp.

References m_name, and m_type.

Register::Register ( const char *  name  ) 

Construct a Register with the given name. If the name is not recognized, then it is assumed to be a GPR register.

Definition at line 135 of file instruction.cpp.

References Register().


Member Function Documentation

bool Register::operator< ( const Register reg  )  const

Returns:
less-than-equality between registers; name is only compared if both registers have type GPR.

Definition at line 141 of file instruction.cpp.

References name(), and type().

bool Register::operator== ( const Register reg  )  const

Returns:
equality between registers; name is only compared if both registers have type GPR.

Definition at line 150 of file instruction.cpp.

References name(), and type().

uchar Register::banks (  )  const

Returns:
0x1 and 0x2 for being addressable from banks 0 and 1 respectively, OR'ed together.

Definition at line 159 of file instruction.cpp.

References m_type.

Referenced by bankDependent().

bool Register::bankDependent (  )  const

Convenience function.

See also:
banks

Definition at line 188 of file instruction.cpp.

References banks().

Referenced by Instr_bsf::behaviour(), Instr_bcf::behaviour(), Instr_xorwf::behaviour(), Instr_swapf::behaviour(), Instr_subwf::behaviour(), Instr_rrf::behaviour(), Instr_rlf::behaviour(), Instr_movwf::behaviour(), Instr_movf::behaviour(), Instr_iorwf::behaviour(), Instr_incf::behaviour(), Instr_decfsz::behaviour(), Instr_decf::behaviour(), Instr_clrf::behaviour(), and Instr_addwf::behaviour().

QString Register::name (  )  const [inline]

Returns the name of the register, or the alias for the GPR.

Definition at line 117 of file instruction.h.

References m_name.

Referenced by Instr_btfss::code(), Instr_btfsc::code(), Instr_bsf::code(), Instr_bcf::code(), Instr_xorwf::code(), Instr_swapf::code(), Instr_subwf::code(), Instr_rrf::code(), Instr_rlf::code(), Instr_movwf::code(), Instr_movf::code(), Instr_iorwf::code(), Instr_incf::code(), Instr_decfsz::code(), Instr_decf::code(), Instr_clrf::code(), Instr_andwf::code(), Instr_addwf::code(), operator<(), and operator==().

Type Register::type (  )  const [inline]

Returns:
the type of register.

Definition at line 121 of file instruction.h.

References m_type.

Referenced by Instr_btfss::behaviour(), Instr_btfsc::behaviour(), Instr_addwf::generateLinksAndStates(), operator<(), and operator==().

bool Register::affectsExternal (  )  const

From the Optimizer's perspective, it is OK to remove, change or add any instruction so long as there are no visible external changes that go against the original intention of the microbe source (a general guiding principle). Therefore, this function returns true for PORT and TRIS registers, false for everything else.

Definition at line 194 of file instruction.cpp.

References m_type.

Referenced by Optimizer::optimizeInstructions().


The documentation for this class was generated from the following files:
Generated on Tue May 8 17:05:57 2007 for KTechLab by  doxygen 1.5.1