/*
NAME DANIEL PACHECO
COURSE ECE 2730
DATE 12/3/23
FILE dpachec_273_001_6.s
PURPOSE: THE PURPOSE OF PROGRAM is to find factorials
*/
/*
FUNCTION Factorial
ARGUMENT No argument
RETURN VALUE No return value
DESCRIPTION: this program finds the factorial of numbers
*/
.global Factorial
Factorial:
/* prolog */
pushl %ebp /* pointer value */
movl %esp, %ebp /* new pointer value */
movl 8(%ebp), %eax /* moves arg to eax */
cmpl $1, %eax /* compares with 1 */
jle returnn /* if arg is less than 1 jump to returnn */
decl %eax /* decrements arg */
pushl %eax /* arg into stack */
call Factorial
addl $4, %esp /* clean stack */
movl 8(%ebp), %edx /* arg into edx */
imull %edx, %eax /* multiply edx by eax*/
jmp return
returnn:
movl $1, %eax /* move 1 to eax */
/* put code here */
return:
/* epilog */
popl %ebp
ret

/* end assembly stub */