SPLat Logo

SPLat/PC: Automatic RAM allocation

NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map

SPLat/PC: Automatic RAM allocation

Automatic RAM allocation was introduced in July 2005 in SPLat/PC V7.15.2. If you have an earlier version of SPLat/PC none of the following applies. You can download the latest version of SPLat/PC from our website.

The purpose of automatic RAM allocation is to free you from having to work out exactly where in RAM to locate each and every variable in your program. It is essentially the same as the capability of programming languages optimized for computing (as distinct from control applications), which allow you to declare variables without concern about where in memory they will be located. As long as there is enough memory, they exist.

The new directives introduced for automatic RAM allocation are:

ByteVarName: defBYTE n

Allocate n bytes

WordVarName: defWORD n

Allocate n words (2 bytes per word)

AddrVarName: defADDR n

Allocate n x 2 bytes for Suspend/Resume address(es) for multitasking.

LongVarName: defLONG n

Allocate n longs (4 bytes each)

FloatVarName: defFLOAT n

Allocate n floating point variables (4 bytes each).

TimeVarName: defTIME24 n

Allocate n SuperTimers (3 bytes each) (In SPLat/PC 7.16.0 and later)

SemVarName: defSEM n

Allocate n bits for a semaphores.

For example, the program line

LoopCount:       defByte    1

will reserve one byte of RAM for a variable called LoopCount. The colon is optional. The address of that RAM byte will be remembered by SPLat/PC, and each time you use it in an instruction that accesses RAM, the numeric address will be substituted for the label LoopCount.

The line

fPressure        defFloat   3

will reserve enough RAM for 3 floating point variables called fPressure. That will mean 12 bytes are reserved (4 bytes per floating point variable). In effect this has declared a 3-element array. The individual values would be addressed using indexed or jndexed addressing.

defFLOAT and defLONG both have the same effect at present. It some future version they may be treated differently, so it is advisable to use the most appropriate one (which almost certainly means defFLOAT). Similarly for defADDR and defWORD.

Each of the above directives is detailed in the Programming Reference under Directives.