title: Binary Bomb Phase 5 issue (my phase 5 seems to be different from everyone elses)
body: <p>So I am working on a Binary Bomb assignment and have gotten stuck. Tried looking at other questions and guides but mine seems to be completely different from what is described in other questions and guides I found on the web. </p>
  
  <p>The phase only takes 2 unsigned ints for input. Here it is disassembled in gdb after being run with 11 2 as input.</p>
  
  <pre><code>Dump of assembler code for function phase_5:
  0x08048ccc &lt;+0&gt;:     push   %ebp
  0x08048ccd &lt;+1&gt;:     mov    %esp,%ebp
  0x08048ccf &lt;+3&gt;:     push   %esi
  0x08048cd0 &lt;+4&gt;:     push   %ebx
  =&gt; 0x08048cd1 &lt;+5&gt;:     sub    $0x20,%esp
  0x08048cd4 &lt;+8&gt;:     lea    -0x10(%ebp),%eax
  0x08048cd7 &lt;+11&gt;:    mov    %eax,0xc(%esp)
  0x08048cdb &lt;+15&gt;:    lea    -0xc(%ebp),%eax
  0x08048cde &lt;+18&gt;:    mov    %eax,0x8(%esp)
  0x08048ce2 &lt;+22&gt;:    movl   $0x8049b0a,0x4(%esp)
  0x08048cea &lt;+30&gt;:    mov    0x8(%ebp),%eax
  0x08048ced &lt;+33&gt;:    mov    %eax,(%esp)
  0x08048cf0 &lt;+36&gt;:    call   0x8048788 &lt;__isoc99_sscanf@plt&gt;
  0x08048cf5 &lt;+41&gt;:    cmp    $0x1,%eax
  0x08048cf8 &lt;+44&gt;:    jg     0x8048cff &lt;phase_5+51&gt;
  0x08048cfa &lt;+46&gt;:    call   0x80492b6 &lt;explode_bomb&gt;
  0x08048cff &lt;+51&gt;:    mov    -0xc(%ebp),%eax
  0x08048d02 &lt;+54&gt;:    and    $0xf,%eax
  0x08048d05 &lt;+57&gt;:    mov    %eax,-0xc(%ebp)
  0x08048d08 &lt;+60&gt;:    cmp    $0xf,%eax
  0x08048d0b &lt;+63&gt;:    je     0x8048d36 &lt;phase_5+106&gt;
  0x08048d0d &lt;+65&gt;:    mov    $0x0,%ecx
  0x08048d12 &lt;+70&gt;:    mov    $0x0,%edx
  0x08048d17 &lt;+75&gt;:    mov    $0x8049960,%ebx
  0x08048d1c &lt;+80&gt;:    add    $0x1,%edx
  0x08048d1f &lt;+83&gt;:    mov    (%ebx,%eax,4),%eax
  0x08048d22 &lt;+86&gt;:    add    %eax,%ecx
  0x08048d24 &lt;+88&gt;:    cmp    $0xf,%eax
  0x08048d27 &lt;+91&gt;:    jne    0x8048d1c &lt;phase_5+80&gt;
  0x08048d29 &lt;+93&gt;:    mov    %eax,-0xc(%ebp)
  0x08048d2c &lt;+96&gt;:    cmp    $0xb,%edx
  0x08048d2f &lt;+99&gt;:    jne    0x8048d36 &lt;phase_5+106&gt;
  0x08048d31 &lt;+101&gt;:   cmp    -0x10(%ebp),%ecx
  0x08048d34 &lt;+104&gt;:   je     0x8048d3b &lt;phase_5+111&gt;
  0x08048d36 &lt;+106&gt;:   call   0x80492b6 &lt;explode_bomb&gt;
  0x08048d3b &lt;+111&gt;:   add    $0x20,%esp
  0x08048d3e &lt;+114&gt;:   pop    %ebx
  0x08048d3f &lt;+115&gt;:   pop    %esi
  0x08048d40 &lt;+116&gt;:   pop    %ebp
  0x08048d41 &lt;+117&gt;:   ret
  </code></pre>
  
  <p>For the line  0x08048d17 &lt;+75>:    mov    $0x8049960,%ebx</p>
  
  <p>I used </p>
  
  <p>x/16b 0x8049960</p>
  
  <p>gdb and it tells me </p>
  
  <p>0x8049960 array.2954: 10      0       0       0       2       0       0      0</p>
  
  <p>0x8049968 array.2954+8:       14      0       0       0       7       0      00</p>
  
  <p>When I go through the program using until until I get to </p>
  
  <p>0x08048d31 &lt;+101>:   cmp    -0x10(%ebp),%ecx</p>
  
  <p>%edx = 11, %ecx = 82, and %ebp-0x10 = 2 (used print to get values for first two and x/d $ebp-0x10 for last one)</p>
  
  <p>Because 82 != 2 it just goes to call explode_bomb.</p>
  
  <p>From what I understand it is reading in my 2 numbers, making sure I entered 2 at &lt;+41>.
  Then it grabs the first number from the array which in this case is 10 and puts it into $eax at +=&lt;+51>. Then it puts eax into -0xc($ebp) at &lt;+57>.</p>
  
  <p>Then it checks to make sure $eax isn't 15 at &lt;+60>, goes on to set $ecx, and $edx to 0. It then passes the pointer to the array to $ebx at &lt;+75>.</p>
  
  <p>Then it enters a loop from &lt;+80> to &lt;+91> but I am not sure what it is really doing. I get that it increments $edx by 1 and the loop is exited when $eax is 15, but I cant figure out how the rest of the stuff works out. </p>
  
  <p>Am I understanding it correctly up to the loop part? And, if someone wouldn't mind explaining what is happening between &lt;+80> and &lt;+91> I would be very grateful. </p>
  
  <p>p.s. Sorry if my formatting is wrong. </p>