0% found this document useful (0 votes)
19 views

Microproce Ssor: Submitted To: Ms - Warda

The document contains a program written to find the factorial of a number entered by the user. The program prompts the user to enter a number, converts it from ASCII to a binary number, initializes the factorial to 1, and uses a loop to repeatedly multiply the factorial by the current number until reaching 1 to calculate the factorial. It then converts the factorial result from binary to ASCII and displays the output.

Uploaded by

alia khan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Microproce Ssor: Submitted To: Ms - Warda

The document contains a program written to find the factorial of a number entered by the user. The program prompts the user to enter a number, converts it from ASCII to a binary number, initializes the factorial to 1, and uses a loop to repeatedly multiply the factorial by the current number until reaching 1 to calculate the factorial. It then converts the factorial result from binary to ASCII and displays the output.

Uploaded by

alia khan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Microproce

ssor
Submitted to:
Ms.Warda
Submitted By:
Saira Rubab
Kanwal Yousaf
Sania Rafique
Ayiza Saeed
H.humera Iqbal
Ainah irfan

Question:
Write a program to find factorial of
number
Code
DATA SEGMENT
NUM DB ?
FACT DB 1H
RES DB 10 DUP ('$')
MSG1 DB "ENTER NUMBER : $"
MSG2 DB 10,13,"RESULT : $"
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,9
INT 21H
MOV AH,1
INT 21H
SUB AL,30H
MOV NUM,AL
MOV AH,0
MOV AL,FACT
MOV CH,0
MOV CL,NUM

LABEL1: MUL CL
LOOP LABEL1
LEA SI,RES
CALL HEX2DEC
LEA DX,MSG2
MOV AH,9
INT 21H
LEA DX,RES
MOV AH,9
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
HEX2DEC PROC NEAR
MOV CX,0
MOV BX,10
LOOP1: MOV DX,0
DIV BX
ADD DL,30H
PUSH DX
INC CX
CMP AX,9
JG LOOP1
ADD AL,30H
MOV [SI],AL
LOOP2: POP AX
INC SI
MOV [SI],AL
LOOP LOOP

RET
HEX2DEC ENDP
END START

Program

Output

You might also like