| Purpose: | Allocate and release a small, temporary, working buffer on the stack. |
| Assumes: | StackAlloc50: there is enough room on the stack to allocate 56 bytes.
StackFree50: SPH and SPL have the same values which they had upon returning from the StackAlloc50() call, so any registers which were PUSHed after that call have already been POPped. StackFree50: MUST use a CALL, not a JMP. |
| Passed: | Nothing |
| Returns: | R31:R30 BYTE * bPtrBuffer pointer to the buffer on the stack |
| Alters: | R0, R26, R27, SPH, SPL, and the FLAGS register |
| Example: |
|
| Notes: | These indicate 50 bytes, but examination of the stack before and after the call (e.g., using the "R" command) will show that actually 56 bytes are allocated and released. The pointer returned by StackAlloc50 is adjusted to place 3 unused (or "slack") bytes both after the buffer begins and before it ends. This is just to try to reduce stack errors, which can be hard to find and almost always sudden and crash the Operating System. |
| Also, StackAlloc50 does not save a pointer for StackFree50 to use; it simply adjusts the stack pointer down by 56 bytes. Similarly, StackFree50 just adjusts the stack pointer upward by 56 bytes. | |
| Finally, if a few bytes mode than 50 are needed, StackAlloc50 may be called more than once, saving R31:R30 ("Z") only after the last return. Of course, call StackFree50 that same number of times to clean up before returning to the caller. | |
| Also see: | StackAlloc250 |