mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-01-13 14:58:30 +00:00
12 lines
388 B
ArmAsm
12 lines
388 B
ArmAsm
factorial:
|
|
pushq %rbx # Preserve frame pointer
|
|
movl %edi, %ebx
|
|
movl $1, %eax
|
|
cmpl $1, %edi
|
|
jle .QUIT # Base case reached: quit
|
|
leal -1(%rdi), %edi # Prepare args for next function call
|
|
call factorial
|
|
imull %ebx, %eax # Use result of function call
|
|
.QUIT:
|
|
popq %rbx # Restore frame pointer
|
|
ret |