%macro rw 4
   mov rax,%1
   mov rdi,%2
   mov rsi,%3
   mov rdx,%4
   syscall
%endmacro

section .data
msg db "factorial of no=", 10
msglen equ $-msg

section .bss
fact resb 1
temp resb 1
temp1 resb 1
section .text
    global _start

  _start:
        
          rw 1,1,msg,msglen              	;display msg            
    mov cl,5
   call Factproc		; Call factorial procedure

; -------------------------Display Code-----------------------
	    mov bp,2
up1:	rol al,4
	    mov [temp],al
	    and al,0fh
	    cmp al,09
	    jbe down1
	    add al,07
down1:	add al,30h
	    mov [temp1],al
	    rw 1,1,temp1,1

	    mov al,byte[temp]
	    dec bp
	    jnz up1
 rw 60,0,0,0
;------------------------Factorial calculation code-----------------

Factproc:
cmp cl,1
jg calculate
mov al,1
ret


calculate:
dec cl
call Factproc
inc cl
mul cl

ret

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: