section .data
    num db 5
section .bss
    fact resq 1  ; Use resq to reserve 8 bytes (quadword) for fact
section .text
    global _start
_start:
    jmp fact_loop
fact_loop:
    mov r8, [fact]
    movzx rax, byte [num]  ; Use movzx to zero-extend the byte to a quadword
    imul r8, rax
    mov [fact], r8
    dec byte [num]
    cmp byte [num], 0
    je end
    jmp fact_loop
end:
    mov rax, 1
    mov rdi, 1
    mov rsi, fact
    mov rdx, 8
    syscall

    mov rax, 60
    xor rdi, rdi
    syscall

Embed on website

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