:care حل شدہ اسائنمنٹس ڈانلوڈ کرنے کے لئے پہلے رجسڑ کریں شکریہ :care

How to write Assembly Language Program using a recursive function

This Section is For Vu Old Solved Programing Assignments From Instructors which will be help full for you finding your Solutions.
Forum rules
Post Only Old Assignments Which are Solved By Instructors Thanks
User avatar
Ali Raza Tawary
Posts: 302
Joined: Fri Dec 22, 2017 8:10 am
Location: Kamalia
Status: Offline


How to write Assembly Language Program using a recursive function

Post by Ali Raza Tawary »

Write a program using a recursive function to calculate the Fibonacci of the last digit of your VU roll number,
i.e. If you roll number is BC123456789 you will calculate the Fibonacci of 9. The calculated Fibonacci
number is stored in the AX register.

Fibonacci(0) = 0
Fibonacci(1) = 1
Fibonacci(n) = Fibonacci(n-1)+ Fibonacci(n+2)

Source:- https://en.wikipedia.org/wiki/Fibonacci_number

Explain each instruction of program with comments and also provide/paste snapshot of your assembled and
debugged program result which will be run in AFD (A Full Screen Debugger) window showing the executed
code and final result i.e. value in AX.

Note: You will only use subroutine to solve the above problem. Marks will not be awarded for using any
other approach.

Note 1: keep name of assembly file according to your VU id , i.e. if your VU id is BC123456789 , you will
keep name of the assembly code file as 23456789.asm i.e. you will use last 8 digits of your id for the code
file name.

Note 2: If the arrays, files names in the screen shots will not be according to your VU id you will get zero

Note 3: In solution file you will write the assembly code and paste two screen shots.

Note 4: You will only use NASM assembler and AFD debugger only.
Answer:; Note: If you have used any other recursive approach, and answer is correct, full marks will be given to you.
; Solution 1
[org  0x0100]
num:    dw   9  ;vu id is bc123456789
start:  mov ax, 0
        mov cx, [num]
        push cx
        call fibonacci
        mov ax, 0x4c00
        int 0x21
           push cx
           cmp cx, 1  ;check for the base condition
        jle stop    
        sub cx, 1
        call fibonacci
        pop cx
        sub cx, 2
        call fibonacci
        pop cx
        add ax, cx

Last 10 Members Who Visited This Topic

User avatar Ali Raza Tawary (2)

Return to “Vu Old Programing Assignments Solutions”

Who is online

Users browsing this forum: No registered users and 1 guest