Need help understanding this practice problem in my reading. Can someone please explain to me what it is doing at every step.
Consider the following assembly code:
x at %ebp+8, n at %ebp+12
1 movl 8(%ebp), %esi //I assume this is x being stored in register
2 movl 12(%ebp), %ebx //Also I think this is n being stored in register
3 movl $-1, %edi
4 movl $1, $edx
5 .L2:
6 movl %edx, %eax
7 andl %esi, %eax
8 xorl %eax, %edi
9 movl %ebx, %ecx
10 sall %cl, %edx
11 test1 %edx, %edx
12 jne .L2
13 movl %edi, %eax
The preceding code was generated by compiling C code that had the following overall form:
int loop(int x, int n)
{
int result = ________;
int mask;
for(mask = ________; mask _________; mask = _________)
result ^= _________;
return result;
}
It's fill in the blanks (obviously). Thanks