title: Reading Assembly Code (Bomb lab phase 5 help)
body: <p>I have to decode this assembly language for the bomb lab:</p>
  
  <pre><code>Dump of assembler code for function phase_5:
  0x08048e79 &lt;+0&gt;:    push   %ebx
  0x08048e7a &lt;+1&gt;:    sub    $0x28,%esp
  0x08048e7d &lt;+4&gt;:    lea    0x1c(%esp),%eax
  0x08048e81 &lt;+8&gt;:    mov    %eax,0xc(%esp)
  0x08048e85 &lt;+12&gt;:   lea    0x18(%esp),%eax
  0x08048e89 &lt;+16&gt;:   mov    %eax,0x8(%esp)
  0x08048e8d &lt;+20&gt;:   movl   $0x804a9de,0x4(%esp)
  0x08048e95 &lt;+28&gt;:   mov    0x30(%esp),%eax
  0x08048e99 &lt;+32&gt;:   mov    %eax,(%esp)
  0x08048e9c &lt;+35&gt;:   call   0x8048940 &lt;__isoc99_sscanf@plt&gt;
  0x08048ea1 &lt;+40&gt;:   cmp    $0x1,%eax
  0x08048ea4 &lt;+43&gt;:   jg     0x8048eab &lt;phase_5+50&gt;
  0x08048ea6 &lt;+45&gt;:   call   0x804961b &lt;explode_bomb&gt;
  0x08048eab &lt;+50&gt;:   mov    0x18(%esp),%eax
  0x08048eaf &lt;+54&gt;:   mov    %eax,%edx
  0x08048eb1 &lt;+56&gt;:   and    $0xf,%edx
  0x08048eb4 &lt;+59&gt;:   cmp    %edx,%eax
  0x08048eb6 &lt;+61&gt;:   je     0x8048ebd &lt;phase_5+68&gt;
  0x08048eb8 &lt;+63&gt;:   call   0x804961b &lt;explode_bomb&gt;
  0x08048ebd &lt;+68&gt;:   mov    0x18(%esp),%ebx
  0x08048ec1 &lt;+72&gt;:   mov    %ebx,%eax
  0x08048ec3 &lt;+74&gt;:   mov    $0x0,%ecx
  0x08048ec8 &lt;+79&gt;:   mov    $0x0,%edx
  0x08048ecd &lt;+84&gt;:   add    $0x1,%edx
  0x08048ed0 &lt;+87&gt;:   add    %eax,%ecx
  0x08048ed2 &lt;+89&gt;:   mov    0x804a700(,%eax,4),%eax
  0x08048ed9 &lt;+96&gt;:   cmp    %eax,%ebx
  0x08048edb &lt;+98&gt;:   jne    0x8048ecd &lt;phase_5+84&gt;
  0x08048edd &lt;+100&gt;:  cmp    0x1c(%esp),%edx
  0x08048ee1 &lt;+104&gt;:  jne    0x8048ee8 &lt;phase_5+111&gt;
  0x08048ee3 &lt;+106&gt;:  cmp    $0x41,%ecx
  0x08048ee6 &lt;+109&gt;:  je     0x8048eed &lt;phase_5+116&gt;
  0x08048ee8 &lt;+111&gt;:  call   0x804961b &lt;explode_bomb&gt;
  0x08048eed &lt;+116&gt;:  add    $0x28,%esp
  0x08048ef0 &lt;+119&gt;:  pop    %ebx
  0x08048ef1 &lt;+120&gt;:  ret
  </code></pre>
  
  <p>I know that up till +68, it basically checks if I have at least 2 ints in the string I inputted.</p>
  
  <p>After it exits the loop, <code>edx</code> must be 4 (at +100 I saw 0x1c(%esp) = 4) and <code>ecx</code> must be 65 (0x41 at +106). Can someone please help me figure out what's going on and what I'd need to input? </p>
  
  <p>***Edit 4/18 (Content of array): 
  It just becomes 0 after %eax = 24 so I think I hit the end. Starting when eax = 5 and traversing through 7 times to when eax = 11, %ecx will = 65 but when I enter "5 7" it doesn't work :(</p>
  
  <pre><code>%eax=0: 0x00000014 
  1:  0x00000008
  2:  0x00000010
  3:  0x00000018
  4:  0x00000005
  5:  0x0000000a
  6:  0x0000000e
  7:  0x0000000d
  8:  0x00000000
  9:  0x00000004
  10: 0x00000016
  11: 0x00000002
  12: 0x00000013
  13: 0x00000017
  14: 0x00000012
  15: 0x00000015
  16: 0x0000000f
  17: 0x0000000c
  18: 0x00000006
  19: 0x00000011
  20: 0x00000001
  21: 0x0000000b
  22: 0x00000009
  23: 0x00000003
  24: 0x00000007
  25: 0x00000000
  26: 0x00000000
  27: 0x00000000
  28: 0x00000000
  29: 0x00000000...
  </code></pre>