Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

BookmarkBookmarked Using Assembly Language write the following program. Problem

ID: 3785177 • Letter: B

Question

BookmarkBookmarked

Using Assembly Language write the following program.

Problem Definition:
Write a program to calculate Fibonacci numbers.
• Display the program title and programmer’s name. Then get the user’s name, and greet the user.
• Prompt the user to enter the number of Fibonacci terms to be displayed. Advise the user to enter an integer in the range [1 .. 46].
• Get and validate the user input (n).
• Calculate and display all of the Fibonacci numbers up to and including the nth term. The results should be displayed 5 terms per line with at least 5 spaces between terms.
• Display a parting message that includes the user’s name, and terminate the program.
Requirements:
1) The programmer’s name and the user’s name must appear in the output.
2) The loop that implements data validation must be implemented as a post-test loop.
3) The loop that calculates the Fibonacci terms must be implemented using the MASM loop instruction.
4) The main procedure must be modularized into at least the following sections (procedures are not required this time):
a. introduction
b. userInstructions
c. getUserData
d. displayFibs
e. farewell
5) Recursive solutions are not acceptable for this assignment. This one is about iteration.
6) The upper limit should be defined and used as a constant.
7) The usual requirements regarding documentation, readability, user-friendliness, etc., apply.

Notes:
1) It is not necessary to store the Fibonacci numbers in an array. The terms may be displayed as they are generated.
2) The second-order Fibonacci sequence is defined as:
a. The first two terms are both 1.
b. All other terms are calculated as the sum of the two previous terms.
c. The reason for restricting n to [1 .. 46] is that the 47th Fibonacci number is too big for DWORD data type

Explanation / Answer

proc getFibonocci

        mov a,f

        mov b,f

    ;mov c,counter

    ;cmp c,number

    ;je exitFibonocci

    mov d,a

    add d,48

    mov ah,02h

    int 21h

    mov c,counter

    add c,1

    mov counter,c

    mov d,b

    add d,48

    mov ah,02h

    int 21h

    mov c,counter

    add c,1

    mov counter,c

    calcFibonocci:

        mov a,f1

        add a,f2

        mov f1,a

        mov d,f1

        add d,48

        mov ah,02h

        int 21h

        mov c,counter

        add c,1

        mov counter,c

        mov c,counter

        cmp c,number

        je exitFibonocci

        mov b,f2

        add b,f1

        mov f2,b

        mov d,f2

        add d,48

        mov ah,02h

        int 21h

        mov c,count

        add c,1

        mov counter,c

        mov c,counter

        cmp c,num

        je exitFibonocci

        jmp calcFibonocci

    exitFibonocci:

    ret

endp

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote