I'm trying to translate the following assembly code to C code:
fct:
movl 4(%esp), %eax
cmpl $0,%eax
jg n
movl $-1,%eax
ret
n: movl $0,%ebx
movl %eax, %ecx
movl $0, %eax
movl $0, %edx
l: addl $2, %ebx
addl %ebx, %eax
addl $1, %edx
cmpl %ecx, %edx
jl l
ret
As I think I can translate most of this pretty easily, I can't seem to find what the first line (movl 4(%esp), %eax
) does. What does 4(%esp) refer to in this context?
I know the %esp register refers to the last instruction of the pile and that 4(%esp) refers to the second one.