汇编网首页登录博客注册
masmaster的学习博客
博客首页博客互动【做检测题】论坛求助

我的博客

个人首页 |  我的文章 |  我的相册 |  我的好友 |  最新访客 |  文章收藏 |  论坛提问 |  友情链接 |  给我留言  
图片载入中
文章收藏

[2010-09-10 10:50] 练习:递归实现阶乘8!

那两道题太难,先放一放。。。。。。这个练习没有考虑8以上的阶乘, 如果需要,就把栈定义好,然后做32位除法。即可。
;-----------------------------------------------------
asume   cs:code
code    segment
start:
        mov ax,8
        mov cx,ax
        call fact
quit:
        call disp
        mov ah,4ch
        int 21h

fact    proc near
        dec cx
        cmp cx,0
        jz ok
        mul cx
        call fact
ok:     
        jmp quit
fact    endp

disp    proc near
        mov bx,10
        mov cx,1
        xor dx,dx
htod:   
        cmp ax,10
        jb ol
        div bx
        add dl,30h
        push dx
        xor dx,dx
        inc cx
        jmp htod
ol:     
        add al,30h
        push ax
show:   
        pop dx
        mov ah,2
        int 21h
        loop show
        ret
disp    endp

code    ends
end     start
;-----------------------------------------------------
PS:杨季文的书错误不少!
评论次数(0)  |  浏览次数(811)  |  类型(程序与练习) |  收藏此文  | 
 
 请输入验证码  (提示:点击验证码输入框,以获取验证码