Python,C,C++ and JAVA programs for CBSE, ISC, B.Tech and I.T Computer Science and MCA students

The Programming Project: PROGRAMMING IN 8086

Sunday, September 29, 2013

PROGRAMMING IN 8086

Fact = N * (N–1)*….2*1  (all are unsigned Word variable)


 TITLE factorial 
;TO COMPUTE
;factorial N <= 8
;----------------------------------------------------------------
     .MODEL SMALL
     .STACK 64
     .DATA
     VAR_N DW 9 
     VAR_FACT DW 1
;----------------------------------------------------------------
     .CODE
MAIN PROC FAR
     MOV AX,@DATA
     MOV DS,AX
     MOV AX,VAR_N 
     MOV DX,01
     CMP AX,00h
     JE SPECIAL
     MOV CX,AX
     MOV BX,AX
     DEC BX      
     DEC CX  
     JZ SPECIAL
     LOOP: MUL BX
           DEC BX 
           DEC CX
           JNZ LOOP         
     MOV DX,AX
     SPECIAL:MOV VAR_FACT,DX
     MOV AX,4C00H
     INT 21H
MAIN ENDP
     END MAIN
    

No comments:

Post a Comment