Symbols
Positron16 · Revision 1.1.3.5 · PDF page 42
The Symbol directive provides a method for aliasing variables and/or constants. Symbol cannot be used to create a variable. Constants declared using Symbol do not use any RAM within the microcontroller.
Symbol cCat = 123
Symbol cTiger = cCat ' cTiger now holds the value of cCat
Symbol cMouse = 1
Symbol cTigOuse = (cTiger + cMouse) ' Add cTiger to cMouse to make cTigOuse
FloatIng point constants may also be created using Symbol by simply adding a decimal point to a value.
Symbol cPI = 3.14 ' Create a floating point constant named cPI
Symbol cFlNum = 5.0 ' Create a floating point constant holding the value 5.0
FloatIng point constant can also be created using expressions.
' Create a floating point constant holding the result of the expression
Symbol cQuanta = (3.3 / 1024)
If a variable or SFR's name is used in a constant expression then the variable's or SFR's address will be substituted, not the value held in the variable or SFR: -
Symbol cMyCon = (PORTB + 1) ' MyCon will hold the value 715 (714+1)
Symbol is also useful for aliasing Ports and SFRs (Special Function Registers): -
Symbol LED_Pin = PORTA.1 ' LED_Pin now references bit-1 of PORTA
Symbol cOSCFAIL = INTCON1.1 ' cOSCFAIL now refers to bit-1 of INTCON1 SFR
