这是求斐波那契数列中25项数的程序:
dec_div macro num
local l1,l2
mov cx,num
div cx
xchg ax,dx
mov bx,ax
cmp ax,0
jne l1
cmp nozero,0
jne l1
jmp l2
l1: mov nozero,1
add dl,30h
mov ah,02h
int 21h
mov ax,bx
mov dx,0
l2:
endm
;***********************************************************
data segment
sum dw 2 dup(?)
nozero db ?
mess db 'the twentyfifth of fibonacci is:','$'
data ends
program segment
main proc far
assume cs:program,ds:data
start:
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
mov ax,0
mov dx,0
mov cx,25
call fibp
lea dx,mess
mov ah,9
int 21h
mov dx,sum[2]
mov ax,sum[0]
dec_div 10000
dec_div 1000
dec_div 100
dec_div 10
dec_div 1
ret
fibp proc near
push cx
cmp cx,2
jz l5
cmp cx,1
jz l5
sub cx,1
call fibp
mov ax,sum[0]
mov dx,sum[2]
push ax
push dx
sub cx,1
call fibp
pop dx
pop ax
pop cx
add sum[0],ax
adc sum[2],dx
ret
l5:
mov sum[0],1
mov sum[2],0
pop cx
ret
fibp endp
main endp
program ends
end start
谁能告诉我dec_div这个宏在程序中的作用到底是什么? 还有就是子程序fibp中的两个递归调用小弟也弄不大清楚,哪位大哥指点一下,在这里先谢过了