Question

In: Computer Science

( Assembly Language ) Write a program that computes the 7th fibonacci number. The fibonacci sequence...

( Assembly Language )

Write a program that computes the 7th fibonacci number.

The fibonacci sequence -

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, …

what is the initialization of a, b, and d?

-

a

b

d

1

?

?

1

2

?

?

1

3

1

1

2

4

1

2

3

5

2

3

5

6

3

5

8

7

5

8

13

wrong initialization

-

a

b

d

1

0

1

1

2

1

1

2

3

1

2

3

4

2

3

5

5

3

5

8

6

5

8

13

7

8

13

21

the following statements are the body of the loop

a := b

b := d

d := a + b

your assembly language code begins here:

N dword 7

FibN dword ?

mov ecx, N

mov eax, 0

mov ebx, 1

toploop:

     …

loop toploop

mov FibN, edx

Solutions

Expert Solution

.MODEL SMALL

.DATA
        NUM_1  DB ?
        NUM_2  DB ?
        NUM_3  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 NUM_1,0
                MOV NUM_2,1

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

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

                
               L1:
                        
                        MOV AL,NUM_1
                        ADD AL,NUM_2
                        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,NUM_2
                        MOV NUM_1,AL
                        MOV NUM_2,BL
                        LOOP L1

                MOV AX,4C00H
                INT 21H

        MAIN ENDP
       END MAIN
       
;*********************************************
;               OUTPUT
;*********************************************

;0 1 1 02 03 05 08 13 21 34 55 89

Related Solutions

Write an assembly language program code to clear and set bit 7th and 19th in a...
Write an assembly language program code to clear and set bit 7th and 19th in a 32-bit variable called N.
Using the MARIE computer assembly language, write a program that computes the following expression: z =...
Using the MARIE computer assembly language, write a program that computes the following expression: z = a * b * c. The computer will read in the input values a, b, and c from the keyboard and the final result (z) have to be displayed. In addition, every time an input value is read in, it must be displayed on the screen. Remember that the instruction set does not have an instruction to execute multiplication. Note: If any of the...
java programing project Implement a program that computes the Fibonacci of a specified number, the factorial...
java programing project Implement a program that computes the Fibonacci of a specified number, the factorial of a specified number, or estimates the value of 'e' using the specified number of iterations (of a Taylor series). Please feel free to use the Internet to find resources that explain how to estimate the value of 'e' using a Taylor series. In the case of no or invalid number of parameters, the program should show help instructions that looks like: --- Assign...
Write a mips assembly language program that asks the user to enter an unsigned number and...
Write a mips assembly language program that asks the user to enter an unsigned number and read it. Then swap the bits at odd positions with those at even positions and display the resulting number. For example, if the user enters the number 9, which has binary representation of 1001, then bit 0 is swapped with bit 1, and bit 2 is swapped with bit 3, resulting in the binary number 0110. Thus, the program should display 6.
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
Write a program in MIPS assembly language to convert an ASCII number string containing positive and...
Write a program in MIPS assembly language to convert an ASCII number string containing positive and negative integer decimal strings, to an integer. Your program should expect register $a0 to hold the address of a nullterminated string containing some combination of the digits 0 through 9. Your program should compute the integer value equivalent to this string of digits, then place the number in register $v0. If a non-digit character appears anywhere in the string, your program should stop with...
Write a MIPS assembly language program to read an arbitrary number of integer pairs from a...
Write a MIPS assembly language program to read an arbitrary number of integer pairs from a file. Each pair will then be multiplied together with the results being accumulated (added together) forming a sum-of-products operation. Submit your report and code here.
Write a C++ program that inputs a sequence of integers into a vector, computes the average,...
Write a C++ program that inputs a sequence of integers into a vector, computes the average, and then outputs the # of input values, the average, and the values themselves. There are 0 or more inputs values, followed by a negative value as the sentinel; the negative value is not stored and not counted. The following sample input: 10 20 0 99 -1 would produce the following output: N: 4 Avg: 32.25 10 20 0 99 The main program has...
Write a C++ program that inputs a sequence of integers into a vector, computes the average,...
Write a C++ program that inputs a sequence of integers into a vector, computes the average, and then outputs the # of input values, the average, and the values themselves. There are 0 or more inputs values, followed by a negative value as the sentinel; the negative value is not stored and not counted. The following sample input: 10 20 0 99 -1 would produce the following output: N: 4 Avg: 32.25 10 20 0 99 The main program has...
Write a sequence of assembly language instructions to subtract each entry of an array A of...
Write a sequence of assembly language instructions to subtract each entry of an array A of five two’s complement 16-bit binary integers from the corresponding entry of an array B of five two’s complement 16-bit binary integers and construct a third array C of two’s complement 16-bit binary integers. i.e. C[i] = A[i] - B[i]. Use the following data for the arrays A and B. A: 10, -15, 20, 4, -5 B: 25, -5, -30, 6, 10 please answer in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT