Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .MODEL LARGE
- .STACK 100
- .DATA
- .CODE
- MAIN PROC
- MOV AX, @DATA
- MOV DS, AX
- CALL FACT ; FACTORIAL PROCEDURE
- CALL PRINT ; PRINT PROCEDURE
- MOV AH, 4CH
- INT 21H
- MAIN ENDP
- FACT PROC ; PROCEDURE START
- MOV CX, 3 ; INPUT
- MOV AX, 1 ; INITIAL WITH 1 FOR MUL
- REPEAT:
- MUL CX ; < AX * CX > 1 * 3
- LOOP REPEAT ; THAN 3 * 2 THAN 6 * 1
- RET
- FACT ENDP ; PROCEDURE END
- PRINT PROC ; PROCEDURE START
- MOV CX, 0
- MOV DX, 0
- MOV BX, 10 ; INITIAL BX = 10 FOR DIV AND GET DIGIT
- SEC1:
- MOV DX, 0
- DIV BX ; AX / BX = 6 / 10
- PUSH DX ; REMAINDER IN DX AND PUSH ON STACK
- INC CX
- CMP AX, 0
- JNE SEC1
- MOV AH, 2
- PRINTLOOP:
- POP DX ; POP ELEMENT AND PUTING IN DX
- ADD DL, 30H
- INT 21H
- LOOP PRINTLOOP
- RET
- PRINT ENDP ; PROCEDURE END
- END MAIN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement