Question

In: Computer Science

Microsoft Visual C++ Assembly language Problem 3. Write a program that uses a loop to calculate...

Microsoft Visual C++ Assembly language

Problem 3. Write a program that uses a loop to calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(1) = 1, Fib(2) = 2, … Fib(n) = Fib(n-1) + Fib(n-2). Place each value in the EAX register and display it with a call DumpRegs statement inside the loop

For example:

Fib(1) = 1,

Fib(2) = 2,

Fib(3) = Fib(1) + Fib(2) = 3,

Fib(4) = Fib(2) + Fib(3) = 5,

Fib(5) = Fib(3) + Fib(4) = 8,

Fib(6) = Fib(4) + Fib(5) = 13,

Fib(7) = Fib(5) + Fib(6) = 21

Below is an assembly program template that you can refer, and complete the programming by filling in the codes into the specified place:

TITLE Midterm Programming Question 3

Comment !

Description: Write a program that uses a loop to calculate the first

seven values in the Fibonacci number sequence { 1,1,2,3,5,8,13 }.

Place each value in the EAX register and display it with a

call DumpRegs statement inside the loop.

!

INCLUDE Irvine32.inc

.code

main PROC

please fill in your code here

            exit

main ENDP

END main

Please submit the source code of your assembly file (i.e. .asm) and the screenshot to show that your program works well

Solutions

Expert Solution

Code:

INCLUDE Irvine32.inc

.code

main PROC

    mov   eax,1

    call DumpRegs

    mov   ebx,0   ;

    mov   edx,1

    mov   ecx,6   ; Counter set to 6

                ;loop will run 0 to 6 = 7 times to print 7 values

    LOOP1: mov eax, ebx

           add eax, edx

           call DumpRegs ;calling DumpRegs inside loop

           mov ebx, edx

           mov edx, eax

    Loop LOOP1

    exit

main ENDP

END main


Related Solutions

Language: c++ works in visual basic Write a program that uses an array of nested structs...
Language: c++ works in visual basic Write a program that uses an array of nested structs to store the addresses for your store’s customers.  Each customer has a name and two addresses: home address and business address.  Each address has a street, city, state, and zip code. Requirements: 1. Data structure a. Define an Address struct with street, city, state and zip fields b. Define a Customer struct with lastNm and firstNm fields, plus homeAddr and busAddr fields...
Write a C-based language program in visual studio that uses an array of structs that stores...
Write a C-based language program in visual studio that uses an array of structs that stores student information including name, age, GPA as a float, and grade level as a string (e.g., “freshmen,”). Write the same program in the same language without using structs.
In visual Studio C++ Create a program that uses a for loop to input the high...
In visual Studio C++ Create a program that uses a for loop to input the high temperature, and low temperature for each day of the week. The high and low will be placed into two elements of the array. For each loop the high and low will be placed into the next set of elements of the array. After the temps for all seven days have been entered into the array, a for loop will be used to pull out...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings in locations str1 and str2. Initialize str1 to Computer and initialize str2 to Compater. Assume Str1 holds the correct spelling and str2 may have an incorrect spelling. Use string instructions to check if str2 is correct and if not correct the mistake in str2.
Please write in x86 Assembly language on Visual Studio. IRVINE32 Write a program to copy one...
Please write in x86 Assembly language on Visual Studio. IRVINE32 Write a program to copy one array of size 24 to another array of size 24 using string instructions. Write 3 versions of this code. One code must copy byte at a time. One code must copy word at a time and one code must copy double word at a time. Cut and paste the array in memory to show your code is working.
Write a program using c++. Write a program that uses a loop to keep asking the...
Write a program using c++. Write a program that uses a loop to keep asking the user for a sentence, and for each sentence tells the user if it is a palindrome or not. The program should keep looping until the user types in END. After that, the program should display a count of how many sentences were typed in and how many palindromes were found. It should then quit. Your program must have (and use) at least four VALUE...
Using C++ language, create a program that uses a struct with array variables that will loop...
Using C++ language, create a program that uses a struct with array variables that will loop at least 3 times and get the below information: First Name Last Name Job Title Employee Number Hours Worked Hourly Wage Number of Deductions Claimed Then, determine if the person is entitled to overtime and gross pay. Afterwards, determine the tax and net pay. Output everything to the screen. Use functions wherever possible. Bonus Points: Use an input file to read in an unknown...
Please use assembly language x86 Visual Studio Write a program to add the following word size...
Please use assembly language x86 Visual Studio Write a program to add the following word size numbers:15F2, 9E89, 8342, 99FF, 7130 using adc instruction and a loop. The result must be in DX, AX. Show the result in debug window.
Write an assembly program (Data and Code) that uses loop to read 10 numbers and output...
Write an assembly program (Data and Code) that uses loop to read 10 numbers and output the largest of those numbers, you can assume any length for those numbers. 80x86 assembly language
in assembly language x86 Masm, Write a program that calculate the first seven values of the...
in assembly language x86 Masm, Write a program that calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(0) = 0, Fib(1) = 1, Fib(2) = Fib(0)+ Fib(1), Fib(n) = Fib(n-1) + Fib(n-2). You NEED to calculate each value in the series "using registers and the ADD operation" You can also use variables, Have your program print out "The first seven numbers is" Use WriteInt for the printing, Place each value in the EAX...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT