REM	This example script doesn't do much; it simply
REM	generates the first 10 numbers in the Fibonacci Sequence
REM	and outputs them to the console.

REM	However, this is a good way to demonstate both
REM	recursion and the stack. Note that the scripting
REM	engine will forcibly stop a script that goes
REM	too deeply into recursive calls, so we can't
REM	list very many Fibonacci numbers this way.


REM	Here's the function we'll be using
REM	Important thing to remember: Stacks don't work
REM	like an array. You'll need to retrieve their
REM	values in the opposite order.
	DEF DoFib
		POP
		STORE b .RESULT
		POP
		STORE a .RESULT
		MATH.ADD a b
		STORE c .RESULT
		OUT c
		GTHAN c 80
		JUMPIF SkipNextCall
		PUSH b
		PUSH c
		CALL DoFib

		LABEL SkipNextCall
	END

REM	And here's the main function
	START
		PUSH 0
		PUSH 1
		CALL DoFib
	END
