Thursday, March 29, 2012

Find the factorial of a given number using 8086 program in assembly language


ASSUME  CS:CODE, DS:DATA, SS:STACK1
DATA SEGMENT
NUM DW 05H
FACT DW 0H
DATA ENDS
STACK1 SEGMENT
STK DW 100H DUP(0H)
TOP_STACK LABEL WORD
STACK1 ENDS
CODE SEGMENT
START:  MOV AX, DATA
        MOV DS, AX
        MOV AX, STACK1
        MOV SS, AX
        LEA SP, TOP_STACK
        MOV AX, NUM
        CALL FACTO1
        MOV AH, 4CH
        INT 21H
        FACTO1 PROC NEAR
        CMP AX, 01H
        JE GO
        PUSH AX
        DEC AX
        CALL FACTO1
        POP AX
        MUL FACT
        MOV FACT, AX
        RET
GO:     MOV FACT,01H
        RET
        FACTO1 ENDP
        CODE ENDS
        END START
     

No comments:

Post a Comment

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...