Handle memory

It actually does. Wait for it (we need some suspense)...

8F7

Trouble is, the processor only has 2048 bytes of memory (0x800 bytes) so it seems its stack is outside available memory.

It (sort of) actually has more memory than that. The first 0x100 memory addresses are the I/O registers. Addresses 0x100 through 0x8FF are SRAM. So, the stack starts at 0x8FF instead of 0x7FF. 0x8F7 indicates eight bytes are on the stack (0x8FF - 0x8F7). CRT0 to main = 2 bytes. main (unfortunately) preserves r28 and r29 = 2 bytes. main to loop = 2 bytes. loop to foo = 2 bytes.