Write a MARIE program to calculate Fib(n)
Answers
Answer:
MARIE program to calculate Fibonacci of any number:
Explanation:
ORG 000
INPUT USER //Takes input from the user
SUBT TWO //Subtracts 2 from it
PRINT, STORE Y //Stores the accumulator Value in Z
CLEAR //AC=0
//TOTAL = N1 + N2
ADD R1 /Adds R1 to AC
ADD R2 //Adds N2 to AC
STORE TOTAL //Store to TOTAL
// R1 = R2
LOAD R2 //Load R2 to AC
STORE R1 //Store to R1
//R2 = TOTAL
LOAD TOTAL //Load TOTAL to AC
STORE R2 //Store R2 to AC
LOAD Y //Load Z to AC
SUBT ONE //Subtracts 1
SKIPCOND 000 //Skip Cond 000 if AC<0
JUMP PRINT //Print Loop
LOAD TOTAL //Load TOTAL in AC
RESULT //Display Output
HALT //Halt Process
//INITILIZATIONS
USER, DEC 0
ONE, DEC 1
TWO, DEC 2
Y, DEC 0
R1, DEC 0
R2, DEC 1
TOTAL, DEC 0
Answer:
The value n can be assigned to determine whatever the number will be determined in the right terms of series. This would go with MARIE program to calculate the Fibonacci services and needs to assign the value of N.
It should computes with value 13 and denotes premature optimization can make program debugging more value. User inputs are taking away with program outputs denotes changes with respect to user inputs.