please help me check code Tasm fibonacci

Reply

Join Date: Sep 2006
Posts: 26
Reputation: vbcielle is an unknown quantity at this point 
Solved Threads: 0
vbcielle vbcielle is offline Offline
Light Poster

please help me check code Tasm fibonacci

 
0
  #1
Feb 1st, 2007
im converting a fibonacci c code to tasm assembly... i've started my code but im having a difficulty in the part where
return fibo(n-1)+fibo(n-2)...please help

the red fonts is where im not sure if my code is correct...can you please help

c code:
int fib(int n)
    {
    if (n <= 2) return 1
    else return fib(n-1) + fib(n-2)
    }

Tasm assembly code:

fibo proc near
    push bp
    mov bp, sp

    push ax
    push bx
    push cx

    mov ax, [bp+6]
    cmp ax,2
    jle one

    sub sp,2
    mov ax, [bp+6]

    push ax
    mov ax, [bp+4]
    push ax
    call fibo
        pop ax
        mov cx, [bp+6]
        add ax
        mov [bp+8], ax
        jmp done 
one:
    mov [bp+8],1
done:
    pop cx
    pop bx
    pop ax
    pop bp
        ret 4
fiboendp
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC