StackAlloc250 and StackFree250

Purpose: Allocate and release a large, temporary, working buffer on the stack.
Assumes: StackAlloc250: there is enough room on the stack to allocate 256 bytes.
StackFree250: SPH and SPL have the same values which they had upon returning from the StackAlloc250() call, so any registers which were PUSHed after that call have already been POPped.
StackFree250: 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: 
WS2812_Show8Bytes:
   CALL    APushAll                ; Need more than a few more Registers
   CALL    AStackAlloc250          ; Allocate 250 bytes on the stack
   MOVW    R10, R30                ; Save the buffer pointer returned
   MOVW    R26, R24                ; Move the caller's data pointer to 'X'
   LDI     R25, 8                  ; Initialize the outer loop for 8 data BYTEs
   LDI     R24, 33                 ; Set the Green component's intensity
   LDI     R22, 27                 ; Set the Red component's intensity

WS2812_8Bytes_Outer:
   LD      R21, X+                 ; Read the next data byte into R22
   LDI     R23, 8                  ; Initialize the bits/byte loop count

WS2812_8Bytes_Inner:
   ROR     R21                     ; Shift the LSBit out to CARRY, all others
   BRCS    AWS2812_8Bytes_Logic1   ;  move right one bit position; CARRY set?
   ST      Z+, R1                  ; Set Green component = 0
   ST      Z+, R1                  ; Set Red   component = 0
   RJMP    AWS2812_8Bytes_Blue     ; Skip past the logic 0 bit

WS2812_8Bytes_Logic1:
   ST      Z+, R24                 ; Set Green = value set above (33)
   ST      Z+, R22                 ; Set Red   = value set above (27)

WS2812_8Bytes_Blue:
   ST      Z+, R1                  ; Set Blue component = 0
   DEC     R23                     ; Decrement the bits/byte counter and loop
   BRNE    AWS2812_8Bytes_Inner    ;  back unless it has reached zero bits
   DEC     R25                     ; Decrement the byte counter and loop back
   BRNE    AWS2812_8Bytes_Outer    ;  until it has processed all 8 bytes

   MOVW    R24, R10                ; Set the buffer pointer for WS2812_Command
;# LDI     R23, 0      ; Already 0 ; R23:R22 number of BYTES to be output: 8
   LDI     R22, 8 * 8 * 3  ; = 192 ;  rows of 8 LED each with 3 BYTEs per LED
   LDI     R20, PORTC              ; R20: ATMega PORT to use to toggle a bit
   MOV     R18, R28                ; R18: the bit(s) to toggle, passed in R28
   ANDI    R18, B00111111          ; Remove the 2 unavailable PORTC bits

   CALL    AWS2812_Command         ; Call to emit the data stream
   CALL    AStackFree250           ; Restore the stack to its value on entry
   JMP     APopAll
Notes: These indicate 250 bytes, but 256 bytes are actually allocated and released. The pointer returned by StackAlloc250 is adjusted to place 3 unused (or "slack") bytes both after the buffer begins and before it ends. This was done just to try to reduce stack errors, which can be hard to find and almost always sudden and crash the O.S.
Also, StackAlloc250 does not save a pointer for StackFree250 to use; it simply adjusts the stack pointer down by 256 bytes. Similarly, StackFree250 just adjusts the stack pointer upward by 256 bytes.
Be VERY careful when calling StackAlloc250 more than once, since stack space is limited and somewhat precious.
Also see:  StackAlloc50