RosettaCodeData/Task/Fibonacci-sequence/EDSAC-order-code/fibonacci-sequence.edsac

53 lines
1.1 KiB
Plaintext

[ Fibonacci sequence
==================
A program for the EDSAC
Calculates the nth Fibonacci
number and displays it at the
top of storage tank 3
The default value of n is 10
To calculate other Fibonacci
numbers, set the starting value
of the count to n-2
Works with Initial Orders 2 ]
T56K [ set load point ]
GK [ set theta ]
[ Orders ]
[ 0 ] T20@ [ a = 0 ]
A17@ [ a += y ]
U18@ [ temp = a ]
A16@ [ a += x ]
T17@ [ y = a; a = 0 ]
A18@ [ a += temp ]
T16@ [ x = a; a = 0 ]
A19@ [ a = count ]
S15@ [ a -= 1 ]
U19@ [ count = a ]
E@ [ if a>=0 go to θ ]
T20@ [ a = 0 ]
A17@ [ a += y ]
T96F [ C(96) = a; a = 0]
ZF [ halt ]
[ Data ]
[ 15 ] P0D [ const: 1 ]
[ 16 ] P0F [ var: x = 0 ]
[ 17 ] P0D [ var: y = 1 ]
[ 18 ] P0F [ var: temp = 0 ]
[ 19 ] P4F [ var: count = 8 ]
[ 20 ] P0F [ used to clear a ]
EZPF [ begin execution ]