Computer Science, asked by chaudharykaran4, 1 year ago

Write a MARIE program to calculate Fib(n),

Answers

Answered by VaibhavKulkarni
0

This is a MARIE program to calculate the Fibonacci series of the given term. The value of ‘n’ will determine the number of Fibonacci terms of the series that the user wants to print.

The program given below calculates the series based on a given set of values which the programmer has decoded to implement.

The MARIE assembly level language program is thus:

ORG 100       //Input Input number

Store N        // The user inputs the number of terms to be printed

Store Ctr      // It stores the counter variable in the accumulator

Loop1, Clear

Load Ctr       // The counter is loaded into the processor form the                                  accumulator

Subt C1         // The counter is subtracted by c1

Store Ctr

Load F2        // F2 is loaded into the accumulator

Add F1           // F1 is added

Store F3        // F3 is stored into the accumulator

Load F1          // F1 is loaded into the accumulator

Store F2         // F2 is stored into the accumulator

Load F3

Store F1

Load Ctr

Skipcond 400       // Check condition is skipped here

Jump Loop1          // Jump condition to the location 400

Load Ctr

Output

Load N                  // Output is N

Output

Load F1                 // the Final output is placed

Output

Halt                       // control halts

N, DEC 0

Ctr, DEC 0

C1, DEC 1

F1, DEC 0

F2, DEC 1

F3, DEC 0

Similar questions