Hello, I am working on the converting the following assembly function into a "C" function.  I setup a activation record to keep track of my parameters and local variables.  I concluded that in the function there are  3 parameters and 3 local variables , the function is a "for loop" since I am doing a cmpl ( 4 <= ( -12(ebp)) and a incl ( Increment) within the function.   Is my reading of the assembly correct ?  Doing the activation record has helped , but I am new to assembly and thus just a bit unsure that I am correct , or at least close to being correct. Any suggestions ?  Thank you for the help.

0x08048408 <foo+0>:     push   %ebp
0x08048409 <foo+1>:     mov    %esp,%ebp
0x0804840b <foo+3>:     sub    $0x10,%esp
0x0804840e <foo+6>:     mov    0x8(%ebp),%eax
0x08048411 <foo+9>:     imul   0xc(%ebp),%eax
0x08048415 <foo+13>:    mov    %eax,0xfffffff4(%ebp)
0x08048418 <foo+16>:    mov    0x10(%ebp),%eax
0x0804841b <foo+19>:    add    0xc(%ebp),%eax
0x0804841e <foo+22>:    mov    %eax,0xfffffff8(%ebp)
0x08048421 <foo+25>:    movl   $0x0,0xfffffffc(%ebp)
0x08048428 <foo+32>:    jmp    0x8048437 <foo+47>
0x0804842a <foo+34>:    mov    0x10(%ebp),%eax
0x0804842d <foo+37>:    lea    0xfffffff8(%ebp),%edx
0x08048430 <foo+40>:    sub    %eax,(%edx)
0x08048432 <foo+42>:    lea    0xfffffffc(%ebp),%eax
0x08048435 <foo+45>:    incl   (%eax)
0x08048437 <foo+47>:    cmpl   $0x4,0xfffffffc(%ebp)
0x0804843b <foo+51>:    jle    0x804842a <foo+34>
0x0804843d <foo+53>:    mov    0xfffffff8(%ebp),%edx
0x08048440 <foo+56>:    mov    0xfffffff4(%ebp),%eax
0x08048443 <foo+59>:    sub    %edx,%eax
0x08048445 <foo+61>:    leave 
0x08048446 <foo+62>:    ret 

Thank you,

Posted on 2008-11-03 23:07:27 by graz