Now the code is here:
.code32
#PURPOSE - Given a number, this program computes the
# factorial. For example, the factorial of
# 3 is 3 * 2 * 1, or 6. The factorial of
# 4 is 4 * 3 * 2 * 1, or 24, and so on.
#
.section .data
#This program has no global data
.section .text
.globl _start
.globl factorial #this is unneeded unless we want to share
_start:
pushl $4
call factorial
addl $4, %esp
#the stack
movl %eax, %ebx
#status
movl $1, %eax
int $0x80
.type factorial,@function
factorial:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
cmpl $1, %eax
je end_factorial
decl %eax
pushl %eax
call factorial
movl 8(%ebp), %ebx
imull %ebx, %eax
end_factorial:
movl %ebp, %esp
popl %ebp
ret
This code is in Programming from the Ground Up I need help to run this code right in WSL2. Well,as the Title,why this ASM-code demo throw segmentation fault in x86/64-Linux machine? I'm new in ASM-code. Thanks from China.