67 279
Assignments Done
99,1%
Successfully Done
In November 2018

Answer to Question #47584 in Assembler for Danielle A

Question #47584
have to calculate the nth term in a tetrabonacci sequence using recursion. in x86 MASM assembly. It is similar to Fibonacci but instead of adding the previous two terms you add the previous four terms. I have written workable code where I get the first 5 n terms tetrabonacci sequence correct. But when n=6 my recursion method seems to not work. Can someone help me with where my code went wrong? .586
.model flat,C

.code

tetrabonacci PROC
push ebp ;save previous pointer
mov ebp,esp ;save current pointer
sub esp, 12 ;make room for local variable ptr
mov eax,[ebp+8] ; get n

;if ((n==1)|| (n==2) ||(n == 3)||(n===4)) return predetermined value, else do recursion on previous 4 terms

cmp eax,4 ; n<=4?
ja recursion ; n > 4 do recursion
jb exception1 ; n< 4 jump to exception1
mov eax,4 ;n=4 move 4 into eax
jmp Quit ;jump to end

exception1:

cmp
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions