There may be times when you decide to use some of the more sophisticated techniques with semaphores, and the automatic memory allocation won't work. In those cases you will need to manually allocate them to known RAM bytes and bits. Examples of when you would need this are:
We have made the semaphore feature in SPLat as flexible as possible, so it is able to use every byte of RAM for semaphores, and they can be used in sophisticated ways. However, for a vast majority of applications you would only need a handful of semaphores, used in a straightforward manner, so you can ignore some of the complexity that invariably comes with the flexibility. This page gives you a simple strategy to use in such cases.
All the semaphore instructions have an argument field that includes the semaphore number ss and a base address bb. In our simple strategy the base address is ignored, and defaults to 0. That means the first 32 bytes of RAM are potentially available as semaphores. In this strategy, though, we actually only use 8 bytes (0 through 7) for semaphores. That will give you 64 semaphores, numbered 0 to 63. As it happens (in fact, it was deliberate planning from day one!), RAM locations 6 and 7 are part of the permanent memory range, so two bytes (16 semaphores) of the designated semaphore area can be saved with PermStore.
The strategy is now defined by the following rules:
If you will never need more than 64 semaphores in your application, that's it, no need to read on