ooPIC Logo

ooPIC Programmer's Guide

 Chapter 5 - Variables and Constants

Back to top of page What are Variables?
 As discussed in Chapter 4 - Programming Fundamentals, Variables are used to store values. In most languages, variables are just a storage area that holds a single value. In the ooPIC languages, variables are objects. The advantage of doing so is that each Variable will have more properties than just its value.

ooPIC provides you with several variables of different sizes and types of Variable Object to accommodate the needs of your program.

Back to top of page Byte and Word Variables
 The Bit, Nibble, Byte, Char, Word, Int Variables are used to store and retrieve a single values.  Each works approximately the same, but the magnitude of the Value is of different sizes.
TypeBit-SizeMagnitudeMemory Size
Bit111
Nib4151
Byte82551
Char8-128 to 1271
Word16655352
Int16-32768 to 327672
Back to top of page Obit, oNibble, oByte and oWord Variable Objects
 The oBit, oNibble, oByte, oChar, oWord and oInt Variable Objects are used to store values. Each of the different Variables types work approximately the same, but the magnitude of the Value property is of different sizes.
 ObjectDescriptionA1A2B1B2C1
oBitManages a 1-bit value with a range of 0 to 1.xxxxx
oNibManages a 4-bit value with a range of 0 to 15.xxxxx
oNibXManages a 4-bit signed value with a range of -8 to +7.x
oByteManages a 8-bit value with a range of 0 to 255.xxxxx
oCharManages a 8-bit signed value with a range of -128 to -127.xxx
oWordManages a 16-bit value with a range of 0 to 65,535.xxxxx
oIntManages a 16-bit signed value with a range of -32,768 to +32,767.xxx
oBuffer(1-32)32 Objects that Manage various sized data-buffer/string variable.xxxxx

Each Variable that is declared in an application will occupy an amount of memory within the ooPIC, and it is always best to use the least amount of memory possible in any application. Therefore, to select the type of Variable to use when needing to store a value, determine the highest value that will be needed and select the Variable type with the lowest Bit-size that will still be able to hold that highest value within its magnitude.

These Variables have a oLogic NonZero property that indicates when the variable is not zero in value.

The two Variables, oByte and oWord have a oLogic MSB property that indicates the state of the Most Significant Bit of the Value Property. The oChar and oInt objects use the MSB as a sign bit when moving between byte and word sizes and other mathematical functions.  Thusly, they have a Negative property instead of a MSB property.

The oBit Variable has the unique feature of having the compiler treat its value property as an oValue AND an oLogic property.  To maintain backwards compatibility, if a oLogic pointer is used to point to the oBit Object or the oBit Object's Value property, the compiler will redirect the pointer automatically to the Data property and no error will occur.

The oValue and oLogic properties can be linked in Virtual Circuits with oValue pointers and oLogic pointers. (See Chapter 8, "Virtual Circuits" For more information on linking oLogic properties to Virtual Circuits)

Back to top of page oPower, oHeading and oDistance Variables
 The oPower, oHeading, oDistance Variables are used to store and retrieve a single values.  Each are URCP variables and are explained in detail in Chapter 15 - URCP.
 ObjectDescriptionA1A2B1B2C1
oDistanceManages a URCP Distance value.xxx
oHeadingManages a URCP Heading value.xxx
oPowerManages a URCP Power value.xxx
Back to top of page oBuffer Variable Object
 The oBuffer Variable is used to store a contiguous group of bytes. It can be defined with as little as 1 byte or as many as 32 bytes of storage.
 ObjectDescriptionA1A2B1B2C1
oBuffer(1-32)32 Objects that Manage various sized data-buffer/string variable.xxxxx

The Value property of the oBuffer Variable is a 1-byte value that access one of the elements in the contiguous group of bytes. The element that the Value property accesses is specified by the Location property.

Back to top of page oEEProm Object
 The oEEProm is a Co-Processor object but can also be thought of as a Variable as it is used to store or retrieve data from nonvolatile memory located within the EEPROM memory chips plugged into the E0 and E1 sockets on the ooPIC.
 ObjectDescriptionA1A2B1B2C1
oEEPromProvides access to an I2C EEPROM memory.xxxxx

Care must be taken when using this Object, as it has the power to access and change the currently running application program.

Back to top of page oRam Object
 The oRam Variable is a PIC Hardware object but can also used to access any one of the 256 locations within the ooPIC object RAM space.
 ObjectDescriptionA1A2B1B2C1
oRAMProvides access to the PIC's Random-Access-Memory.xxxxx

Extreme care must be taken when using this Object, as it has the power to access and change critical OS operations.  

Back to top of page Constants
 A Constant is a value that is given a name. Like a Variable, a constant is referred to in code to retrieve its value. However, unlike a Variable, its value can only be defined once within the code and cannot be changed during program execution.

ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.