Subject Computer Science Assembly Language Programming

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...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Assisting Tutor

Related Homework Solutions

Iterative Factorial Calculation in Assembly
Homework Solution
$10.00
Computer Science
Programming
Iterative Factorial Calculation
Assembly Language
Loops
Functions
Input
Output
Procedures
Error Conditions
Assembly Language Problems
Homework Solution
$50.00
Programming
Computer Science
Assembly Language
Characters
Calendars
Video Mode
Variables
Keyboard Navigation
Commands
Assembly Language Problems With Fibonacci Numbers
Homework Solution
$30.00
Assembly Language
Computer Science
Programming
Fibonacci Numbers
Arrays
European Mathematics
Indian Mathematics
Sequences
Characters
Strings
Columns
Rows
Values
Memory
Stack
Macros
Boolean
Registers
Get help from a qualified tutor
Live Chats