TITLE    Fibonacci_file
INCLUDE C:\irvine\Irvine32.inc;Generate the first 47 NO. of the Pibonacci.
;Store them into a dword array.
;Store the array into disk.
;Needn't use the I/O error test.
;Try to use debug or VS open the file and view the content.It should be 188 byte..data
;Fisrt Count of the Fibonacci
Count=47
Outputfile byte "OutPut.txt"
Fibonacciarray dword Count dup(0),0
FileHandle dword ?
Buffer byte Count dup(?)
ByteWriten dword ?.code
main PROC
;Create the output file
;the offset of the filename-Outputfile t edxmov edx,offset Outputfile call createoutputfile

;filehandle of the created file-in eax,to the variant FileHandle
mov FileHandle,eax;Create the Fibonacci;......in the Fibonacci array ....a,b,c......
;a->bmeans assign a to b
;iterate (a+b->d,d->c's right element,b->a,d->b,0->d)
;first and the second Fibonacci element 1->a,b
;eax,ebx,edx respective means a,b,d,exc means c's right element
mov eax,1
mov ebx,1
mov edx,0;assign first 2 element 1,1 in FFF
mov Fibonacciarray,eax
mov Fibonacciarray+type dword,ebx
;iterate Count-2(45) times
mov ecx,Count-2
;esi as a pointer offset the Fibonacciarray
mov esi,offset 2*type dwordL:
add edx,eax
add edx,ebx
mov Fibonacciarray[esi],edx
add esi,type dword
mov eax,ebx
mov ebx,edx
mov edx,0
loop L mov esi,offset Fibonacciarray
mov ecx,Count
mov ebx,type dword
call dumpmem
mov eax,FileHandle
mov edx,offset Fibonacciarray
mov ecx,Count
call WriteToFile
mov ByteWriten,eax
exit
main ENDP
END main