Q: I'm trying to write the first 47 Fibonacci numbers to a disk file. What should I fix? ; This program will store the first 47 Fibonacci numbers in an array of doublewords and write the doubleword array to a disk file

include Irvine32.inc

FibCount = 45

.data

    fileName BYTE "Fib47", 0    ; Creates file name
    FibArray DWORD ?            ; Initializes DWORD array to store fibonacci numbers

.code

main PROC

    mov ecx, FibCount
    mov esi, OFFSET FibArray
    call CreateOutputFile
    call computeFibonacciNumbers
    call WriteToFile

    exit
main ENDP

;-----------------------------------------------
; Computes Fibonacci numbers (type DWORD) and stores them in an array
; Receives: ECX = count of Fibonacci numbers
;           ESI = offset of array of Fibonacci numbers
; Returns: nothing
;----------------------------------------------

computeFibonacciNumbers PROC

    mov eax, 1
    mov ebx, 1

L1:
    cmp ecx, 0
    jbe L2
    add eax, ebx
    mov edx, eax
    mov FibArray, edx
    mov ebx, eax
    mov edx, ebx
    loop L1

L2:
    ret

computeFibonacciNumbers ENDP

END main


A: mov ecx, FibCount
mov esi, OFFSET FibArray
call CreateOutputFile
call computeFibonacciNumbers

Why do you call CreateOutputFile between the setup of the arguments for computeFibonacciNumbers and the actual calling of computeFibonacciNumbers? Highly illogical and prone to errors.
FibArray DWORD ?            ; Initializes DWORD array to store fibonacci numbers

Your setup of FibArray just prepares room for 1 dword. If you want room for an array of 47 elements then write:
FibArray DWORD 47 dup(?)



*

*The computeFibonacciNumbers procedure has ESI for an argument, yet you don't use it anywhere.

*In this procedure you're moving all the values on top of each other. Better write mov [esi],edx add esi,4

*You can savely move the cmp ecx,0 jbe L2 before the loop. You need not retest this condition.

*You loop does not require the use of EDX at all.
