previous | start

Annotated phase_1

08048568 <phase_1>:             ; phase_1(char s[])
        ;; setup stack frame for phase_1
 8048568:       55                      push   %ebp
 8048569:       89 e5                   mov    %esp,%ebp
 804856b:       83 ec 38                sub    $0x38,%esp
  ;; ?? place (not push) parameters on stack before calling sscanf
  ; -0x24(%ebp)  local variable: a
 804856e:       8d 45 ec                lea    0xffffffec(%ebp),%eax 
  ; make %edx contain address a + 8
 8048571:       8d 50 08                lea    0x8(%eax),%edx 
 ; make %eax contain address a
 8048574:       8d 45 ec                lea    0xffffffec(%ebp),%eax 
 ; now make %eax contain address a + 4
 8048577:       83 c0 04                add    $0x4,%eax 
 ; move address a + 8 to %esp + 16
 804857a:       89 54 24 10             mov    %edx,0x10(%esp)
 ; move address a + 4 to %esp + 12 
 804857e:       89 44 24 0c             mov    %eax,0xc(%esp) 
 ; make %eax contain address a
 8048582:       8d 45 ec                lea    0xffffffec(%ebp),%eax 
 ; address a moved to %esp + 8
 8048585:       89 44 24 08             mov    %eax,0x8(%esp) 
 ; something moved to %esp + 4
 8048589:       c7 44 24 04 48 87 04    movl   $0x8048748,0x4(%esp) 
 8048590:       08
 ; move 1st param to %eax
 8048591:       8b 45 08                mov    0x8(%ebp),%eax 
 ; move 1st param, s,  to address %esp + 0
 8048594:       89 04 24                mov    %eax,(%esp) 
        ;; call sscanf - look at previous instructions for parameters
 ; sscanf(s, fmt, a, a + 4, a + 8)
 8048597:       e8 08 fe ff ff          call   80483a4 <sscanf@plt>
 ; -8(%ebp) local variable:  n = return value from sscanf
 804859c:       89 45 f8                mov    %eax,0xfffffff8(%ebp) 
        ;; checking number of conversions by sscanf
 804859f:       83 7d f8 03             cmpl   $0x3,0xfffffff8(%ebp) ;
 ; if (n == 3) goto 80485aa
 80485a3:       74 05                   je     80485aa <phase_1+0x42>
 80485a5:       e8 2e 00 00 00          call   80485d8 <explode> ; call explode
        ;; ok 3 numbers read. what next?
 ; -4(%ebp) local variable:  b = 0
 80485aa:       c7 45 fc 00 00 00 00    movl   $0x0,0xfffffffc(%ebp) 
 ; n = n - 1
 80485b1:       83 6d f8 01             subl   $0x1,0xfffffff8(%ebp) 
        ;; loop starts with unconditional jump to test (at end of loop body)
 80485b5:       eb 0e                   jmp    80485c5 <phase_1+0x5d> ; goto 80485c5
 80485b7:       8b 45 f8                mov    0xfffffff8(%ebp),%eax ;
                %eax contains n
 ; -0x24(%ebp) + 4 * n moved to %eax - that is, %eax = a[n]
 80485ba:       8b 44 85 ec             mov 0xffffffec(%ebp,%eax,4),%eax 
 80485be:       01 45 fc                add    %eax,0xfffffffc(%ebp) ; b = b + a[n]
 80485c1:       83 6d f8 01             subl   $0x1,0xfffffff8(%ebp) ; n = n - 1
 80485c5:       83 7d f8 00             cmpl   $0x0,0xfffffff8(%ebp) ;
 80485c9:       79 ec                   jns    80485b7 <phase_1+0x4f> ; if (n >= 0) goto 8045b7 
     ;jns means jump if the comparison was not negative (not 'signed'; jge)
 80485cb:       83 7d fc 12             cmpl   $0x12,0xfffffffc(%ebp) ;
 80485cf:       74 05                   je     80485d6 <phase_1+0x6e> ; if (b == 0x12) goto 80485d6
 80485d1:       e8 02 00 00 00          call   80485d8 <explode> ; call explode
 80485d6:       c9                      leave
 80485d7:       c3                      ret


previous | start