0

What is this code doing exactly?

mystery:
pushl %ebp
movl %esp, %ebp
subl $20, %esp
movl $0, -4(%ebp)
jmp .L2
.L3:
movl -4(%ebp), %eax
sall $2, %eax
addl 8(%ebp), %eax
movl (%eax), %eax
cmpl 16(%ebp), %eax
jne .L4
movl $1, -20(%ebp)
jmp .L6
.L4:
addl $1, -4(%ebp)
.L2:
movl -4(%ebp), %eax
cmpl 12(%ebp), %eax
jl .L3
movl $0, -20(%ebp)
.L6:
movl -20(%ebp), %eax
leave
ret
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by wildgoose
0

Sounds like a class problem.

On a piece of paper create rows

Passed Arguments
[16]
[12]
[8]
[4]
[0]
[-4]
[-8]
[-12]
[-16]
[-20]
Temporaries

Mark which one of these is your return address, and your passed in arguments, your temporary local arguments and then single-step your code!

Anything else before you do that would be doing your homework for you!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.