Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It doesn't look like you have the whole function, but here's a breakdown of what's here:</p> <p>These 3 instructions set up your stack frame:</p> <pre><code>0x080486a8 &lt;myFunction+0&gt;: push %ebp 0x080486a9 &lt;myFunction+1&gt;: mov %esp,%ebp 0x080486ab &lt;myFunction+3&gt;: sub $0x1c,%esp </code></pre> <p>I'm not sure what this is for:</p> <pre><code>0x080486ae &lt;myFunction+6&gt;: call 0x8048418 &lt;mcount@plt&gt; </code></pre> <p>This is i and sum getting initialized to 0 (the are stored on the stack):</p> <pre><code>0x080486b3 &lt;myFunction+11&gt;: movl $0x0,-0x4(%ebp) 0x080486ba &lt;myFunction+18&gt;: movl $0x0,-0xc(%ebp) </code></pre> <p>This is the beginning of the outer for loop. Typically, a loop in assembly starts by jumping to the end. The end in this case is past the end of your assembly listing. </p> <pre><code>0x080486c1 &lt;myFunction+25&gt;: jmp 0x8048713 &lt;myFunction+107&gt; </code></pre> <p>This is j getting initialized to 0. It's done here because it has to be reset every time the outer for loop runs. </p> <pre><code>0x080486c3 &lt;myFunction+27&gt;: movl $0x0,-0x8(%ebp) </code></pre> <p>This is the beginning of the inner for loop. </p> <pre><code>0x080486ca &lt;myFunction+34&gt;: jmp 0x8048707 &lt;myFunction+95&gt; </code></pre> <p>This indexes array by i*2 by doing pointer arithmetic on the address of array. First it puts i into eax, then left shifts it 3 (multiplying it by 8). This is an optimization of the *2 as well as accounting for the size of elements of array (4). Finally it adds this to the address of array, storing the result in eax. </p> <pre><code>0x080486cc &lt;myFunction+36&gt;: mov -0xc(%ebp),%eax 0x080486cf &lt;myFunction+39&gt;: shl $0x3,%eax 0x080486d2 &lt;myFunction+42&gt;: add 0xc(%ebp),%eax </code></pre> <p>This takes the value pointed to by address calculated above and stores it in edx. In this dialect of assembly x(y) means *(y+x) </p> <pre><code>0x080486d5 &lt;myFunction+45&gt;: mov (%eax),%edx </code></pre> <p>This calculates array[j] in a similar fashion, storing the result in eax this time:</p> <pre><code>0x080486d7 &lt;myFunction+47&gt;: mov -0x8(%ebp),%eax 0x080486da &lt;myFunction+50&gt;: shl $0x2,%eax 0x080486dd &lt;myFunction+53&gt;: add 0xc(%ebp),%eax 0x080486e0 &lt;myFunction+56&gt;: mov (%eax),%eax </code></pre> <p>This checks the two calculations above to see if they are equal: </p> <pre><code>0x080486e2 &lt;myFunction+58&gt;: cmp %eax,%edx </code></pre> <p>If the check doesn't pass (if they are not equal), skip the inside of the if. (This jumps past the end of your listing) jne means "jump if not equal"</p> <pre><code>0x080486e4 &lt;myFunction+60&gt;: jne 0x8048703 &lt;myFunction+91&gt; </code></pre> <p>These instructions load the arguments of mySumFunction into the proper places:</p> <pre><code>0x080486e6 &lt;myFunction+62&gt;: movl $0x6,0x8(%esp) 0x080486ee &lt;myFunction+70&gt;: mov 0xc(%ebp),%eax 0x080486f1 &lt;myFunction+73&gt;: mov %eax,0x4(%esp) </code></pre> <p>If the listing is cut off here, but hopefully this gives you a good general idea. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload