How to resolve the algorithm Fibonacci sequence step by step in the x86 Assembly programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Fibonacci sequence step by step in the x86 Assembly programming language
Table of Contents
Problem Statement
The Fibonacci sequence is a sequence Fn of natural numbers defined recursively:
Write a function to generate the nth Fibonacci number. Solutions can be iterative or recursive (though recursive solutions are generally considered too slow and are mostly used as an exercise in recursion). The sequence is sometimes extended into negative numbers by using a straightforward inverse of the positive definition: support for negative n in the solution is optional.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Fibonacci sequence step by step in the x86 Assembly programming language
Source code in the x86 programming language
TITLE i hate visual studio 4 (Fibs.asm)
; __ __/--------\
; >__ \ / | |\
; \ \___/ @ \ / \__________________
; \____ \ / \\\
; \____ Coded with love by: |||
; \ Alexander Alvonellos |||
; | 9/29/2011 / ||
; | | MM
; | |--------------| |
; |< | |< |
; | | | |
; |mmmmmm| |mmmmm|
;; Epic Win.
INCLUDE Irvine32.inc
.data
BEERCOUNT = 48;
Fibs dd 0, 1, BEERCOUNT DUP(0);
.code
main PROC
; I am not responsible for this code.
; They made me write it, against my will.
;Here be dragons
mov esi, offset Fibs; offset array; ;;were to start (start)
mov ecx, BEERCOUNT; ;;count of items (how many)
mov ebx, 4; ;;size (in number of bytes)
call DumpMem;
mov ecx, BEERCOUNT; ;//http://www.wolframalpha.com/input/?i=F ib%5B47%5D+%3E+4294967295
mov esi, offset Fibs
NextPlease:;
mov eax, [esi]; ;//Get me the data from location at ESI
add eax, [esi+4]; ;//add into the eax the data at esi + another double (next mem loc)
mov [esi+8], eax; ;//Move that data into the memory location after the second number
add esi, 4; ;//Update the pointer
loop NextPlease; ;//Thank you sir, may I have another?
;Here be dragons
mov esi, offset Fibs; offset array; ;;were to start (start)
mov ecx, BEERCOUNT; ;;count of items (how many)
mov ebx, 4; ;;size (in number of bytes)
call DumpMem;
exit ; exit to operating system
main ENDP
END main
You may also check:How to resolve the algorithm Conditional structures step by step in the MiniScript programming language
You may also check:How to resolve the algorithm Make directory path step by step in the Scala programming language
You may also check:How to resolve the algorithm Monte Carlo methods step by step in the PHP programming language
You may also check:How to resolve the algorithm Five weekends step by step in the Ruby programming language
You may also check:How to resolve the algorithm Write entire file step by step in the Nim programming language