【发布时间】:2015-11-06 03:04:08
【问题描述】:
; 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
【问题讨论】:
-
对于初学者,您应该在问题中尽可能详细地解释什么是不工作的。
标签: assembly fibonacci irvine32