Thursday, April 26, 2012

Program for factorial of a number

MY_DATA SEGMENT
    NUMBER DW STORE_NUMBER_HERE
    MY_FACT DW ??
MY_DATA ENDS

CODE SEGMENT
    ASSUME CS:CODE, DS:DATA
    ; INITLISE DATA SEGMENT
    MOV AX, MY_DATA
    MOV DS, AX
   
    MOV AX, 1
    ; INITILISE AX WITH 1
    MOV BX, NUMBER
   
BACK:    MUL BX
    DEC BX
    JNZ BACK
    MOV MY_FACT, AX
    ; STORE ANSWER IN MY_FACT
    HLT
; PROGRAM ENDS
CODE ENDS
END   

No comments:

Post a Comment