I'm trying to figure out what this block of assembly code is doing:
mystery:
.LFB0
testl %edi, %edi
je .L3
subq $8, %rsp
shrl $2, %edi
call mystery
addq $1, %rax
jmp .L2
.L3:
movl $l, %eax
ret
.L2:
addq $8, %rsp
ret
So far I have this as the C code:
long mystery(unsigned n){
if(n==0)
return 1;
And I get that there is a recursive function going on here while n!=0 but I don't understand what the %rsp register is doing
Here's my guess:
#include <inttypes.h>
int64_t mystery(int32_t n) {
if (n == 0) {
return 1;
}
return 1 + mystery(n / 4);
}
I don't know what the $l
is in the line:
movl $l, %eax
so my above solution assumes it's a typo for $1
. Enlighten me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.