小小递归程序

求n的阶乘,键盘输入n,结果存储在AX中。

 1 DATA SEGMENT
 2 
 3 DATA ENDS
 4 STACK1 SEGMENT STACK
 5     DB 50H DUP(0)
 6 STACK1 ENDS
 7 CODE SEGMENT
 8     ASSUME CS:CODE,DS:DATA,SS:STACK1
 9 START:  MOV AX,DATA
10     MOV DS,AX
11     MOV AH,1    ;INPUT (AL)
12     INT 21H
13     XOR AH,AH
14     SUB AL,30H
15     MOV DX,1
16     CALL DIGUI
17         MOV AH,4CH    ;RETURN DOS
18     INT 21H
19 DIGUI   PROC    NEAR
20         CMP AL,0
21     JE RET1
22     PUSH AX
23     DEC AL
24     CALL DIGUI
25     POP AX
26     MUL DL
27     MOV DX,AX
28 RET1:   RET
29 DIGUI   ENDP
30 CODE ENDS
31     END START

 

posted @ 2014-12-11 00:53  jiu~  阅读(205)  评论(0编辑  收藏  举报