Question
Need help adjusting this ASM program. The program asks the user to input an N integer value and then prints out the first N values
Need help adjusting this 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"
Need to adjust the program so that it uses an ARRAY to print the values and prints them in REVERSE. Ex: "Fibonacci sequence is: 55 34 21 13 8 5 3 2 1 1 0"
Code:
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started