Tuesday, 2 February 2016

Factorial Assembly Code | Factorial Program in Assembly Language | Assembly Language Program to Find Factorial of a Number

Factorial Assembly Code | Factorial Program in Assembly Language | Assembly Language Program to Find Factorial of a Number

Download Factorial Assembly Code


[org 0x0100]

jmp main

factorial:
   push bp
   mov bp , sp
   push ax
   push dx
   cmp word [bp+4] , 1
   je exit
  
   sub sp , 2
   mov ax , [bp+4]
   dec ax
   push ax
   call factorial
   pop ax
   mov dx , 0
   mul word [bp+4]
   mov [bp+6] , ax
   jmp exit2
  
   exit:
      mov word [bp+6] , 1
     
   exit2:
      pop dx
      pop ax
      pop bp
      ret 2
     
main:
   sub sp , 2
   push 7
   call factorial
   pop ax
  
   mov ax , 0x4c00
   int 0x21


No comments

Post a Comment

Recent Posts