;*********************************
;计算N!
data
segment
n
dw
3
result
dw
?
;存放结果
data
ends
sstack
segment
stack
dw
512
dup(?)
sstack
ends
main
segment
assume cs:main,ds:data,ss:sstack
start:
mov
ax,data
mov
ds,ax
push
ax
push
n
call
far ptr
fact
pop
result
mov
al,result
add
al,30h
mov
dl,al
mov
ah,2
;输出结果
int
21h
mov
ax,4c00h
int
21h
main
ends
sub1
segment
assume
cs:sub1,ss:sstack
;**********************************************
;递归计算N!
fact
proc
far
push
bp
mov
bp,sp
push
ax
push
dx
mov
ax,[bp+6]
cmp
ax,0
jnz
fact1
mov
ax,1
jmp
exit
fact1:
sub
sp,2
dec
ax
push
ax
call
fact
pop
ax
mul
word ptr [bp+6]
exit:
mov
[bp+8],ax
pop
dx
pop
ax
pop
bp
ret
2
fact
endp
sub1
ends
end
start
;***********************************************************
;你修改一下这个程序,估计就差不多了