RAM Allocation: Ground rules
The auto-allocation scheme is designed to co-exist with manual allocation. There are a few rules you need to remember to make the most of both schemes.
RAM used by auto-allocation
Auto-allocation will use the following RAM:
- For normal data, anything above location 19 (inclusive) that has not been assigned in
mEQUdirectives. - For semaphores, anything above location 32 (inclusive) that has not been assigned in
mEQUdirectives.
How much RAM mEQU uses
mEQU now has an optional byte count argument. For example
Foo: mEQU 12,8
will mark locations 12 through 19 (8 bytes) as used and give label Foo the value 12. If you omit the second argument, it is taken to be 4 (to conservatively allow space for a floating point variable).
mEQU allocations can be overlapped.
SPLat/PC will let you reference the same RAM location any number of times in mEQU directives. That means that you are totally responsible for managing the memory allocated with mEQU directives. It also allows you to allocate the same RAM to different purposes if you are quite sure they will be used at different times by your program. This can be dangerous but can conserve RAM.
You should not know where auto-allocated variables are stored
You may be able to work out where your auto-allocated variables are stored, but don’t try and use that knowledge beyond very immediate debugging. There is no guarantee they won’t move next time you edit your program, next time you translate it, next week or when we release a new version of SPLat/PC.