Find the factorial using loop in assembly

Bismillahir Rahmanir Rahim
Solution: 

if 1
include mylib1.lib
endif
mydata segment
fact dd 01h 
num db ? 
mydata ends

mystack segment
db 100 dup(0)
mystack ends

mycode segment
assume cs:mycode, ds:mydata, ss:mystack
start:
mov ax, seg mydata
mov ds, ax
mov ax, seg mystack

mov ah,01h
int 21h; al = ascii
sub al,30h; al=bin
mov num, al
mov ah,00h
mov cx,ax
mov bx,01h
mov ax, word ptr fact ; ax = multiplicand
back: mul bx
 inc bx
 loop back
mov word ptr fact,ax
mov word ptr [fact+2],dx


mov bx,word ptr [fact+2]
printh
mov bx,word ptr fact
printh

 

mov ax, 4c00h
int 21h

printfh

mycode ends
end start

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →