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
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment