Find limit of recursion is part of Short Circuit's Console Program Basics selection.
Task

Find the limit of recursion.




org &0000
LD SP,&FFFF ;3 bytes
loop:
or a ;1 byte, clears the carry flag
ld (&0024),sp ;4 bytes
ld hl,(&0024) ;3 bytes
push af ;1 byte
ld bc,(&0024) ;4 bytes
sbc hl,bc    ;4 bytes
jr z,loop    ;2 bytes
jr *         ;2 bytes
;address &0024 begins here
word 0       ;placeholder for stack pointer