Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!