Write and run a 8086 assembly language program that finds the factorial of first N natural numbers. The value of N is input to the assembly program. The factorial value is stored in AX register. Assume that the value of N is between 1 and 5 only.
; 8086 assembly Language
; DosBox
org 100h
.model small
.stack 200h
.data
.code
start:
mov ax,@data ;set segment DATA
mov ds,ax
mov es,ax
mov cx,5
mov ax,1
; ax = 5*4*3*2*1
l1:
mul cx ; dx:ax <- ax*cx
loop l1
mov ah, 4ch
int 21h ; exit
end start
Comments
Leave a comment