.model small .code main proc far start: xor ax,ax push ds push ax mov ax,24 push ax call Fibonacci ret main endp Fibonacci proc near push bp mov bp,sp add sp,-4 mov cx,[bp+4] cmp cx,2 ja recursive mov ax,1 add sp,4 pop bp ret 2 recursive: mov word ptr[bp-4],cx dec cx push cx call Fibonacci mov word ptr[bp-2],ax dec cx push cx call Fibonacci add ax,word ptr[bp-2] mov cx,word ptr[bp-4] add sp,4 pop bp ret 2 Fibonacci endp end start 测试数据 Fibonacci(24) = 46368 |