 # Fibonacci Number Sequence

## Question

Write a program that uses a loop to calculate the first 12 values in the Fibonacci number sequence { 1,1,2,3,5,8,13,21,34,55,89,144}. First, place each value in the EAX register and display it with a callDumpRegs statement inside the loop.
EAX=00000001 EBX=7FFDF000 ECX=00000000 EDX=0040100A
ESI=00000000 EDI=00000000 EBP=0012FF94 ESP=0012FF8C
EIP=0040103A EFL=00000246 CF=0 SF=0 ZF=1 OF=0 AF=0 PF=1
... ... ... ... ... ...
EAX=00000090 EBX=00000037 ECX=00000001 EDX=00000059
ESI=00000000 EDI=00000000 EBP=0012FF94 ESP=0012FF8C
EIP=00401052 EFL=00000216 CF=0 SF=0 ZF=0 OF=0 AF=1 PF=1
Press any key to continue ...

Second, modify your code to save each Fibonacci number into memory, a BYTE array, and call DumpMem to display your result.
Dump of offset 00405050
-------------------------------
01 01 02 03 05 08 0D 15 22 37 59 90
Press any key to continue ...

As a basic rule, if you can use registers, don’t use memory either direct or indirect operands. In this exercise, there are enough registers to use. Only operation for memory is to move a calculated Fibonacci number into your Fibonacci array. If well designed, only 4 or 5 instructions necessary in the loop body.

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

INCLUDE Irvine32.inc

ExitProcess PROTO, dwExitCode:DWORD

.data

fibarray BYTE 12 DUP(?) ;Declare an array of 12 bytes

.code

main PROC
mov eax,1 ; mov the first member of array to eax register
call DumpRegs ; show the registers...
\$25.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Assembly Language Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.