Name Muhammad Osama
[Link] Sp23-Bcs-072
Tutor [Link]
Lab Report: Recursive Factorial Calculation in Assembly
Language (8086)
Objective
The objective of this lab task is to implement recursion in assembly language on the 8086
microprocessor to calculate the factorial of a given number and store the result in RAM.
This task demonstrates the use of stack operations, recursive calls, and proper memory
management.
Code
mov ax, 0200h
mov sp, 0400h
mov ax, 0300h
mov ds, ax
mov ax, 4
call recursion
mov [0100h], ax
hlt
recursion proc
cmp ax, 1
jz end_rec
push ax
dec ax
call recursion
pop bx
mul bx
end_rec:
ret
recursion endp
mov ax, 0200h
mov ss, ax
mov sp, 0400h
mov ax, 0300h
mov ds, ax
mov ax, 4
call recursion
mov [0100h], ax
hlt
recursion proc
cmp ax,1
jz end_rec
push ax
dec ax
call recursion
pop bx
mul bx
end_rec:
ret
recursion endp