TITLE Fibonacci Numbers (Fibonacci.asm)
INCLUDE Irvine32.inc
.data
prompt1 BYTE "Find the first N values of the Fibonacci numbers.", 0Dh, 0Ah
BYTE 0Dh, 0Ah, "Enter the value of N (positive integer): ", 0
prompt2 BYTE 0Dh, 0Ah, "Overflow at N = ", 0
prompt3 BYTE " ", 0
n DWORD ?
|
.code
main PROC
call Clrscr
mov edx, OFFSET prompt1
call WriteString
call ReadInt
mov n, eax
call Crlf
mov esi, 1 ; esi = 1, 2, 3, 4, 5, 6, 7, ...
; eax = 1, 1, 2, 3, 5, 8, 13, ...
mov edi, 1 ; edi = 1, 2, 3, 4, 5, 1, 2, ...
mov ecx, n ; Computes and prints N numbers.
mov eax, 1 ; Initializes Fib(1) = 1.
mov ebx, 0 ; Fib(2) = Fib(1) + 0.
|
|