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

Write a program using assembly language that generates the first n numbers of th

ID: 3697699 • Letter: W

Question

Write a program using assembly language that generates the first n numbers of the Fibonacci series. In this series, the first two numbers are 0 and 1, and each subsequent number is generated by adding the preceding two numbers.

For example, for n = 8, the series is 0, 1, 1, 2, 3, 5, 8, 13

Fib(n) = Fib(n — 1) + Fib(n — 2)

Your program should store the numbers in successive memory word locations starting at 0x10010000 The “n” number should be a variable that can be changed in the code. Program must be able to run and compile using MIPS simulator to examine the memory locations starting at 0x10010000.

Explanation / Answer

.DATA
        NUM1 DB *
        NUM2 DB *
        NUM3 DB *
        V1     DB *
        V2     DB *
        NL     DB ' ', 0DH,0AH,'$'
      

.CODE                 
       MAIN PROC
                MOV AX,@DATA
                MOV DX,AX
                MOV CX,10
                MOV CH,0
              
                MOV NUM1,0
                MOV NUM2,1

                MOV DL,NUM1
              
                OR DL,30H
                MOV AH,02H
                INT 21H

                MOV DL,NUM2
                OR DL,30H
              
                MOV AH,02H
                INT 21H

              
               L1:
                      
                        MOV AL,NUM1
                        ADD AL,NUM2
                        MOV AH,0
                        MOV BL,AL
                        MOV DL,10
                        DIV DL
                        ADD AX,3030H

                        MOV V1,AL
                        MOV V2,AH

                        MOV DL,V1
                        MOV AH,02H
                        INT 21H
                      
                        MOV DL,V2
                        MOV AH,02H
                        INT 21H

                SHIFT:
                        MOV AL,NUM2
                        MOV NUM1,AL
                        MOV NUM2,BL
                        LOOP L1

                MOV AX,4C00H
                INT 21H

        MAIN ENDP
       END MAIN

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