PIC14 Class Reference

#include <pic14.h>

Collaboration diagram for PIC14:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Type {
  P16C84, P16F84, P16F627, P16F628,
  unknown
}
enum  LocationType { num = 1, work = 2, var = 3 }
enum  DelaySubroutine {
  Delay_None = 0, Delay_3uS = 1, Delay_768uS = 2, Delay_200mS = 3,
  Delay_50S = 4
}

Public Member Functions

 PIC14 (Microbe *master, Type type)
 ~PIC14 ()
Type type () const
QString minimalTypeString () const
PortPin toPortPin (const QString &portPinString)
uchar gprStart () const
void setParser (Parser *parser)
void setCode (Code *code)
void mergeCode (Code *code)
void setConditionalCode (Code *ifCode, Code *elseCode)
CodeifCode ()
CodeelseCode ()
void postCompileConstruct (const QStringList &interrupts)
bool isValidPort (const QString &portName) const
bool isValidPortPin (const PortPin &portPin) const
bool isValidTris (const QString &trisName) const
bool isValidInterrupt (const QString &interruptName) const
void Sgoto (const QString &label)
void Slabel (const QString &label)
void Send ()
void Ssubroutine (const QString &procName, Code *compiledProcCode)
void Sinterrupt (const QString &procName, Code *compiledProcCode)
void Scall (const QString &name)
void Ssetlh (const PortPin &portPin, bool high)
void add (QString val1, QString val2, LocationType val1Type, LocationType val2Type)
void subtract (const QString &val1, const QString &val2, LocationType val1Type, LocationType val2Type)
void mul (QString val1, QString val2, LocationType val1Type, LocationType val2Type)
void div (const QString &val1, const QString &val2, LocationType val1Type, LocationType val2Type)
void assignNum (const QString &val)
void assignVar (const QString &val)
void saveToReg (const QString &dest)
void saveResultToVar (const QString &var)
void equal (const QString &val1, const QString &val2, LocationType val1Type, LocationType val2Type)
void notEqual (const QString &val1, const QString &val2, LocationType val1Type, LocationType val2Type)
void greaterThan (const QString &val1, const QString &val2, LocationType val1Type, LocationType val2Type)
void lessThan (const QString &val1, const QString &val2, LocationType val1Type, LocationType val2Type)
void greaterOrEqual (const QString &val1, const QString &val2, LocationType val1Type, LocationType val2Type)
void lessOrEqual (const QString &val1, const QString &val2, LocationType val1Type, LocationType val2Type)
void bitwise (Expression::Operation op, const QString &val1, const QString &val2, bool val1IsNum, bool val2IsNum)
void Swhile (Code *whileCode, const QString &expression)
void Srepeat (Code *repeatCode, const QString &expression)
void Sif (Code *ifCode, Code *elseCode, const QString &expression)
void Sfor (Code *forCode, Code *initCode, const QString &expression, const QString &variable, const QString &step, bool stepPositive)
void Spin (const PortPin &portPin, bool NOT)
void addCommonFunctions (DelaySubroutine delay)
void Sdelay (unsigned length_us, Code::InstructionPosition pos=Code::Middle)
void SsevenSegment (const Variable &pinMap)
void Skeypad (const Variable &pinMap)
void SincVar (const QString &var)
void SdecVar (const QString &var)
void SrotlVar (const QString &var)
void SrotrVar (const QString &var)
void Stristate (const QString &port)
void Sasm (const QString &raw)

Static Public Member Functions

static Type toType (const QString &text)

Public Attributes

Codem_ifCode
Codem_elseCode

Protected Member Functions

void multiply ()
void divide ()
void ifInitCode (const QString &val1, const QString &val2, LocationType val1Type, LocationType val2Type)
void rearrangeOpArguments (QString *val1, QString *val2, LocationType *val1Type, LocationType *val2Type)
int interruptNameToBit (const QString &name, bool flag)

Protected Attributes

Type m_type
Parserm_parser
Microbemb
Codem_pCode

Detailed Description

Author:
Daniel Clarke

David Saxton

Definition at line 70 of file pic14.h.


Member Enumeration Documentation

enum PIC14::DelaySubroutine

Used in determining which delay subroutine should be created.

Definition at line 90 of file pic14.h.


Member Function Documentation

PIC14::Type PIC14::toType ( const QString &  text  )  [static]

Tries to convert the string to a PIC type, returning unknown if unsuccessful.

Definition at line 122 of file pic14.cpp.

Referenced by Microbe::compile().

Type PIC14::type (  )  const [inline]

Returns:
the PIC type.

Definition at line 110 of file pic14.h.

References m_type.

QString PIC14::minimalTypeString (  )  const

Returns:
the Type as a string without the P at the front.

Definition at line 143 of file pic14.cpp.

References m_type.

Referenced by Code::generateCode().

PortPin PIC14::toPortPin ( const QString &  portPinString  ) 

Translates the portPinString (e.g. "PORTA.2") into a PortPin if the port and pin combination is valid (otherwise returns an invalid PortPin with a pin of -1.

Definition at line 65 of file pic14.cpp.

References isValidPortPin().

Referenced by Parser::processAssignment().

uchar PIC14::gprStart (  )  const

Returns the address that the General Purpose Registers starts at.

Definition at line 101 of file pic14.cpp.

References m_type.

Referenced by Code::generateCode().

bool PIC14::isValidPort ( const QString &  portName  )  const

Returns:
whether or not the port is valid.
See also:
isValidPortPin

Definition at line 252 of file pic14.cpp.

Referenced by Parser::processAssignment().

bool PIC14::isValidPortPin ( const PortPin portPin  )  const

Returns:
whether or not the port and pin is a valid combination.
See also:
isValidPort

Definition at line 259 of file pic14.cpp.

References PortPin::pin(), and PortPin::port().

Referenced by toPortPin().

void PIC14::saveResultToVar ( const QString &  var  ) 

Move the contents of the working register to the register with the given name.

Definition at line 410 of file pic14.cpp.

References Code::append(), and m_pCode.

Referenced by Parser::processAssignment(), and Stristate().

void PIC14::equal ( const QString &  val1,
const QString &  val2,
LocationType  val1Type,
LocationType  val2Type 
)

Code for "=="

Definition at line 587 of file pic14.cpp.

References Code::append(), elseCode(), ifCode(), ifInitCode(), m_pCode, mb, mergeCode(), Code::queueLabel(), and Microbe::uniqueLabel().

void PIC14::notEqual ( const QString &  val1,
const QString &  val2,
LocationType  val1Type,
LocationType  val2Type 
)

Code for "!="

Definition at line 605 of file pic14.cpp.

References Code::append(), elseCode(), ifCode(), ifInitCode(), m_pCode, mb, mergeCode(), Code::queueLabel(), and Microbe::uniqueLabel().

void PIC14::greaterThan ( const QString &  val1,
const QString &  val2,
LocationType  val1Type,
LocationType  val2Type 
)

Code for ">"

Definition at line 623 of file pic14.cpp.

References Code::append(), elseCode(), ifCode(), ifInitCode(), m_pCode, mb, mergeCode(), Code::queueLabel(), and Microbe::uniqueLabel().

void PIC14::lessThan ( const QString &  val1,
const QString &  val2,
LocationType  val1Type,
LocationType  val2Type 
)

Code for "<"

Definition at line 640 of file pic14.cpp.

References Code::append(), elseCode(), ifCode(), ifInitCode(), m_pCode, mb, mergeCode(), Code::queueLabel(), and Microbe::uniqueLabel().

void PIC14::greaterOrEqual ( const QString &  val1,
const QString &  val2,
LocationType  val1Type,
LocationType  val2Type 
)

Code for ">="

Definition at line 661 of file pic14.cpp.

References Code::append(), elseCode(), ifCode(), ifInitCode(), m_pCode, mb, mergeCode(), Code::queueLabel(), and Microbe::uniqueLabel().

void PIC14::lessOrEqual ( const QString &  val1,
const QString &  val2,
LocationType  val1Type,
LocationType  val2Type 
)

Code for "<="

Definition at line 681 of file pic14.cpp.

References Code::append(), elseCode(), ifCode(), ifInitCode(), m_pCode, mb, mergeCode(), Code::queueLabel(), and Microbe::uniqueLabel().

void PIC14::Sdelay ( unsigned  length_us,
Code::InstructionPosition  pos = Code::Middle 
)

Delay the program execution, for the given period of length_us (unit: microseconds).

Parameters:
pos the position to add the code for calling the delay subroutine.

Definition at line 791 of file pic14.cpp.

References Microbe::addDelayRoutineWanted(), Code::append(), m_pCode, and mb.

Referenced by Skeypad().

void PIC14::SsevenSegment ( const Variable pinMap  ) 

Output the working register to the given seven segment.

Parameters:
name The variable giving the pin configuration of the seven segment.

Definition at line 895 of file pic14.cpp.

References Code::append(), Code::instruction(), m_pCode, Variable::name(), Variable::portPinList(), Code::queueLabel(), Code::Subroutine, and Variable::type().

Referenced by Parser::processAssignment().

void PIC14::Skeypad ( const Variable pinMap  ) 

Read the value of the keypad to the working register.

Parameters:
name The variable giving the pin configuration of the keypad.

Definition at line 1016 of file pic14.cpp.

References Microbe::alias(), Code::append(), Code::instruction(), m_pCode, mb, Variable::name(), Variable::portPinList(), Code::queueLabel(), Sdelay(), Code::Subroutine, and Variable::type().

void PIC14::rearrangeOpArguments ( QString *  val1,
QString *  val2,
LocationType val1Type,
LocationType val2Type 
) [protected]

The function makes sure that val1 always contains a working register variable, if one has been passed, this is done by swapping val1 and val2 when neccessary

Definition at line 345 of file pic14.cpp.

Referenced by add(), and mul().

int PIC14::interruptNameToBit ( const QString &  name,
bool  flag 
) [protected]

Parameters:
flag True means give flag bit, false means give enable bit instead

Definition at line 228 of file pic14.cpp.

Referenced by postCompileConstruct(), and Sinterrupt().


Member Data Documentation

Type PIC14::m_type [protected]

See also:
Microbe::m_picType

Definition at line 232 of file pic14.h.

Referenced by gprStart(), isValidInterrupt(), minimalTypeString(), PIC14(), and type().


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