Knowledge Base

SPLat/PC: Manual RAM allocation

In the old (prior to July 2005) RAM allocation scheme RAM (Data Memory) was allocated to specific variables using the mEQU (or EQU) directive. For example:

Foo:    mEQU     34

would (and still will) define the label (symbol) Foo as being equivalent to the numerical value 34. This is turn means that if you subsequently use Foo as a RAM address argument in any instruction that references RAM, the value 34 will be used in its place. For example:

        IncM     Foo

will increment the contents of RAM location 34 if it exists in the same program as the previous sample line.

This is all documented in the SPLat/PC help file. Using this allocation scheme you must manually manage where in RAM each variable is to be located.

With the new automatic allocation scheme, the old EQU and mEQU directives still work. However, mEQU has been modified to work better with the new system, and now has an optional second argument. The second argument tells SPLat/PC how many bytes to reserve. RAM reserved by mEQU directives will not be used by the new automatic RAM allocation. That means you can safely mix and match the two schemes. For example, you may decide to upgrade an old program that uses the manual allocation scheme. It is perfectly OK to use automatic allocation for any new variable you need for your additional code.

The line

Bar:    mEQU     35,3

will set aside the 3 RAM locations 35, 36 and 37. These then become unavailable to the automatic allocation scheme. If the optional second argument is not included, SPLat/PC assumes 4. This ensures that if you are going to use the memory for a 4-byte floating point variable, it won’t get re-allocated by the automatic allocation scheme (that would be bad!).

Note however that there is nothing to stop you overlapping allocations within the manual scheme. The following is perfectly legal:

Var1:   mEQU      27,5
Var2:   mEQU      28

You might do this for either of the following reasons:

  1. You made a mistake (the manual allocation scheme provides no protection)
  2. You intended to re-use memory. Maybe different parts of your program use it at separate times, so you can save by sharing.