.var and .tempvar (also .tvar)

.var size|type, name

This is another way to declare a label, designed to make adding variables which point to some location of safe RAM easier. The size argument is in bytes - 1 declares a byte, 2 a word, 324 a 324 byte region. The name is just any old label name (local label rules still apply!)

Available types are:

Type Description Size CastableDefinable
byte Signed byte 1
ubyte Unsigned byte 1
asc ASCII character 1
word Signed word 2
uword Unsigned word 2
int Signed integer 4
uint Unsigned integer 4
fpX.Y Signed fixed-point number Variable
ufpX.Y Unsigned fixed-point numberVariable
tifloat TI floating-point number 9
Any structure User-defined structure Variable

You can also declare instances of structures (see the .struct notes for more information).

Fixed-point variables are sized depending on which values you specify for X and Y. For example, fp8.8 is a 16-bit fixed point number, with 8 bits for the integer part and 8 bits for the fractional part. fp16.8 would have 16 bits in the integer part and 8 in the fractional part, 24-bits (3 bytes) total.

Variables defined using .tempvar or .tvar are designed for temporary variables. Temporary variables defined in one module can potentially overwrite temporary variables defined in another module (as long as the modules do not overlap - for example, if one module is a child of the other).

You can declare an array of variables using square brackets and a size - for example:

.var fp8.8[256], TrigTable

This would declare an variable 512 bytes in size (fp8.8 would be 2 bytes per variable).

See .varloc for examples.