;*****************************************************************************
;Fibo_simple
;In a Fibonacci series each number is the sum of the two previous ones, 
;e.g. 0,1,1,2,3,5,8,13,21....
;This program calculates Fibonacci numbers within an 8-bit range. 
;Program intended for simulation only, hence no input/output.
;TJW 6.11.08					 Tested by simulation 6.11.08
;****************************************************************************

;these memory locations hold the Fibonacci series
fib0	equ  20	;lowest number 
fib1    equ  21 ;middle number
fib2    equ  22 ;highest number
fibtemp equ  23 ;temporary location for newest number

	    org 00
;preload initial values
		clrf fib0		;clear location fibo
		movlw 1			;move value 1 to W register
		movwf fib1		;move W register to fib1
		movwf fib2		;move W register to fib2
;
forward movf  fib1,0    ;move the contents of fib1 to W register
		addwf fib2,0		;add W reg to fib2
		movwf fibtemp		;move new number formed to fibtemp
;now shuffle numbers held, discarding the oldest (ie fib0)
		movf  fib1,0 		;move fib1 to W register
		movwf fib0		;move W register to fib0
		movf  fib2,0		;move fib2 to W register
		movwf fib1		;move W register to fib1
		movf  fibtemp,0 	;move fibtemp to W register
		movwf fib2		;move W register to fib2
		goto  forward
		end