Answer to Question #272636 in Assembler for Ankit

Question #272636

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.


1
Expert's answer
2021-11-28T05:30:59-0500
; 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

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS