Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help adjusting this assembly (ASM) program. The program asks the user to input an N integer value and then prints out the first N

Need help adjusting this assembly (ASM) program. The program asks the user to input an N integer value and then prints out the first N values of the Fibonacci sequence. So if the input is N = 10, then it will print "Fibonacci sequence is: 0 1 1 2 3 5 8 13 21 34 55"

The program needs to be adjusted so it prints the values IN REVERSE

So it would instead print "Fibonacci sequence is: 55 34 21 13 8 5 3 2 1 1 0"

Program:

INCLUDE Irvine32.inc INCLUDELIB Irvine32.lib

.data msg1 BYTE "Please enter a number", 0dh, 0ah, 0 msg2 BYTE "Febonacci sequence is: ", 0 spce BYTE " ", 0 .code

main proc mov ecx, 0 mov edx, OFFSET msg1 call WriteString call ReadInt mov ecx, eax mov edx, eax push ecx push edx call fib add esp, 4 mov eax, 0 mov ebx, 1 mov edx, OFFSET msg2 call WriteString pop edx pop ecx mov ecx, 0 mov ecx, edx inc ecx

L1:

jecxz quit add ebx, eax call WriteDec mov edx, OFFSET spce call WriteString xchg eax, ebx loop L1 call crlf

quit:

exit main ENDP

fib proc c

push ebp mov ebp, esp add ecx, 1 sub esp, 4 mov eax, [ebp + 8] cmp eax, 2 je next cmp eax, 1 je next dec eax push eax call fib mov [ebp - 4], eax dec dword ptr[esp] call fib add esp, 4 add eax, [ebp - 4] jmp Quit next:

mov eax, 1

Quit:

mov esp, ebp pop ebp ret fib ENDP end main

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions