Hello once again on this site with a new problem.
I am writing a program for calculating Fibonnaci series term for specified input.
Have written the following code, but gives me some pointer dangle error.
I think I have handled stack management well. Cant figure out the problem
TITLE fibonacci
Include Irvine32.inc
.data
.code
fibo PROC ; Procedure for calculating fibonnaci.
push ebp
mov ebp, esp
push ebx
push ecx
mov ecx, [ebp+8]
cmp ecx, 2
jae greater ; jump if n >= 2
mov eax, 1 ;returns 1 in EAX
pop ecx
pop ebx
pop ebp
ret 4
greater:
add ecx, -1 ; n = n-1 (for fib(n-1) )
push ecx
call fibo
mov ebx, eax
pop ecx
add ecx, -1 ; n = n-1 (for fib(n-2) )
push ecx
call fibo
add eax, ebx
pop ecx
pop ecx
pop ebx
pop ebp
ret 4
fibo ENDP
main PROC
push 5
call fibo
call writeint
call dumpregs
exit
main ENDP
END main
The error displayed it:
Unhandled page fault on read access to 0x00000003 at address 0x3 (thread 0017), starting debugger...