vbcielle 0 Light Poster

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.