Consider the recursive implementation of the factorial function
fact: ; recursive function
n equ 8
push rbp
mov rbp, rsp
sub rsp, 16 ;make roomfor storing n cmp rdi, 1 ; compare argumentwith 1
jg greater ; if n <=1, return 1
mov eax, 1 ; set return value to 1
leave
ret
greater:mov [rsp+n] , rdi ; save n
dec rdi ; call factwith n -1
call factmov rdi, [rsp+n] ; restore original n
imul rax, rdi ;multiply fact(n-1) n
leave
ret
1 Explain how the above code actually accomplishes recursion
2 Either using a step by step debugger or by manually executing the instructions as would an appropriate ISA computer (that is, you show each step and intermediate result), go through the rst three recursions of ten factorial and display each of the steps and values of the dierent relevant variables and relevant registers of the machine.
3 How does the recursion end - as a concrete example, what happens for ten factorial as the nal returned value is being computed and why does the recursion stop?