# Fibonacci using terminfo's native integer addition, driven by the last digit of the seconds of /usr/bin/top header clock # # export TERMINFO="$PWD"; tic fib_top.txt; TERM=fib_top /usr/bin/top # # Registers: # A = F(N-1) # B = F(N) # N = current Fibonacci index and initialization flag # # Fibonacci step: # push A, push B, add # stack: A+B # push B, pop into A # A = old B # pop into B # B = A+B # N = N + 1 # # On each cup: # if p1 == 0 and p2 == 78: # if N == 0: initialize # else: step # update the title # emit the requested cursor move fib_top,cup= # advance one step when top addresses the seconds digit at (0,78) %?%p1%{0}%=%p2%{78}%=%A%t\ %?%gN%{0}%=%t\ %{0}%PA%{1}%PB%{1}%PN\ %e\ %gA%gB%+%gB%PA%PB%gN%{1}%+%PN\ %;\ %; # show the current result in the window title \E]0;F(%gN%d)=%gB%d\007 # emit the cursor move top requested \E[%p1%{1}%+%d;%p2%{1}%+%dH,