Program to generate Fibonacci series
7. Program to generate Fibonacci series :
mov r1,#0ah ;Load r1 with immediate data 0ahmov dptr,#9000h ;load 9000h into dptr register
movx a,@dptr ; move data from external memory location to a
inc dptr ;increment dptr
mov r0,a ;move data from a to r0
movx a,@dptr ; move data from external memory location to a
back:mov r2,a ;move data from a to r2
add a,r0 ;add a and r0
inc dptr ;increment dptr
movx @dptr,a ;move data from a to external memory location
mov r3,a ;move data from a to r3
mov a,r2 ; move data from r2 to a
mov r0,a ; move data from a to r0
mov a,r3 ; move data from r3 to a
djnz r1,back ;decrement r1, if not 0, jump to label back
here:sjmp here
end
Output:00 01 01 02 03 05 08 0bh, 15h, 22h