1 Replies - 955 Views - Last Post: 19 May 2012 - 06:39 PM

#1 batm  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-May 12

Clarification on recursion in assembly

Posted 19 May 2012 - 06:32 PM

08048f26 <transform>:
 8048f26:       55                      push   %ebp
 8048f27:       89 e5                   mov    %esp,%ebp
 8048f29:       83 ec 28                sub    $0x28,%esp
 8048f2c:       c7 45 f8 0e 00 00 00    movl   $0xe,0xfffffff8(%ebp)
 8048f33:       8b 45 f8                mov    0xfffffff8(%ebp),%eax
 8048f36:       01 c0                   add    %eax,%eax
 8048f38:       89 45 fc                mov    %eax,0xfffffffc(%ebp)
 8048f3b:       8b 45 08                mov    0x8(%ebp),%eax
 8048f3e:       83 e8 71                sub    $0x71,%eax
 8048f41:       89 45 ec                mov    %eax,0xffffffec(%ebp)
 8048f44:       83 7d ec 0a             cmpl   $0xa,0xffffffec(%ebp)
 8048f48:       77 7d                   ja     8048fc7 <transform+0xa1>
 8048f4a:       8b 55 ec                mov    0xffffffec(%ebp),%edx
 8048f4d:       8b 04 95 28 a3 04 08    mov    0x804a328(,%edx,4),%eax
 8048f54:       ff e0                   jmp    *%eax
 8048f56:       c7 45 fc 39 00 00 00    movl   $0x39,0xfffffffc(%ebp)
 8048f5d:       e8 1e 10 00 00          call   8049f80 <explode_bomb>
 8048f62:       c7 45 fc 4b 00 00 00    movl   $0x4b,0xfffffffc(%ebp)
 8048f69:       8b 45 f8                mov    0xfffffff8(%ebp),%eax
 8048f6c:       6b c0 64                imul   $0x64,%eax,%eax
 8048f6f:       89 45 f8                mov    %eax,0xfffffff8(%ebp)
 8048f72:       e9 81 00 00 00          jmp    8048ff8 <transform+0xd2>
 8048f77:       8b 45 f8                mov    0xfffffff8(%ebp),%eax
 8048f7a:       89 c2                   mov    %eax,%edx
 8048f7c:       c1 e2 02                shl    $0x2,%edx
 8048f7f:       01 c2                   add    %eax,%edx
 8048f81:       8d 04 d5 00 00 00 00    lea    0x0(,%edx,8),%eax
 8048f88:       89 45 f8                mov    %eax,0xfffffff8(%ebp)
 8048f8b:       8b 55 f8                mov    0xfffffff8(%ebp),%edx
 8048f8e:       89 d0                   mov    %edx,%eax
 8048f90:       c1 e8 1f                shr    $0x1f,%eax
 8048f93:       01 d0                   add    %edx,%eax
 8048f95:       d1 f8                   sar    %eax
 8048f97:       89 45 f8                mov    %eax,0xfffffff8(%ebp)
 8048f9a:       c7 45 fc 5a 00 00 00    movl   $0x5a,0xfffffffc(%ebp)
 8048fa1:       eb 55                   jmp    8048ff8 <transform+0xd2>
 8048fa3:       c7 45 fc 8b ff ff ff    movl   $0xffffff8b,0xfffffffc(%ebp)
 8048faa:       f7 5d f8                negl   0xfffffff8(%ebp)
 8048fad:       f7 5d fc                negl   0xfffffffc(%ebp)
 8048fb0:       e8 cb 0f 00 00          call   8049f80 <explode_bomb>
 8048fb5:       83 6d f8 36             subl   $0x36,0xfffffff8(%ebp)
 8048fb9:       8b 45 08                mov    0x8(%ebp),%eax
 8048fbc:       01 45 f8                add    %eax,0xfffffff8(%ebp)
 8048fbf:       8b 45 fc                mov    0xfffffffc(%ebp),%eax
 8048fc2:       29 45 f8                sub    %eax,0xfffffff8(%ebp)
 8048fc5:       eb 31                   jmp    8048ff8 <transform+0xd2>
 8048fc7:       8b 45 08                mov    0x8(%ebp),%eax
 8048fca:       89 45 e8                mov    %eax,0xffffffe8(%ebp)
 8048fcd:       c7 45 e4 56 55 55 55    movl   $0x55555556,0xffffffe4(%ebp)
 8048fd4:       8b 45 e4                mov    0xffffffe4(%ebp),%eax
 8048fd7:       f7 6d e8                imull  0xffffffe8(%ebp)
 8048fda:       89 d1                   mov    %edx,%ecx
 8048fdc:       8b 45 e8                mov    0xffffffe8(%ebp),%eax
 8048fdf:       c1 f8 1f                sar    $0x1f,%eax
 8048fe2:       89 ca                   mov    %ecx,%edx
 8048fe4:       29 c2                   sub    %eax,%edx
 8048fe6:       8b 45 fc                mov    0xfffffffc(%ebp),%eax
 8048fe9:       03 45 f8                add    0xfffffff8(%ebp),%eax
 8048fec:       8d 04 02                lea    (%edx,%eax,1),%eax
 8048fef:       89 45 f8                mov    %eax,0xfffffff8(%ebp)
 8048ff2:       8b 45 fc                mov    0xfffffffc(%ebp),%eax
 8048ff5:       01 45 f8                add    %eax,0xfffffff8(%ebp)
 8048ff8:       8b 55 fc                mov    0xfffffffc(%ebp),%edx
 8048ffb:       8b 45 f8                mov    0xfffffff8(%ebp),%eax
 8048ffe:       29 d0                   sub    %edx,%eax
 8049000:       c9                      leave  
 8049001:       c3                      ret    

08049002 <level_4>:
 8049002:       55                      push   %ebp
 8049003:       89 e5                   mov    %esp,%ebp
 8049005:       83 ec 28                sub    $0x28,%esp
 8049008:       8d 45 fc                lea    0xfffffffc(%ebp),%eax
 804900b:       89 44 24 08             mov    %eax,0x8(%esp)
 804900f:       c7 44 24 04 54 a3 04    movl   $0x804a354,0x4(%esp)
 8049016:       08 
 8049017:       8b 45 08                mov    0x8(%ebp),%eax
 804901a:       89 04 24                mov    %eax,(%esp)
 804901d:       e8 ee fa ff ff          call   8048b10 <sscanf@plt>
 8049022:       83 f8 01                cmp    $0x1,%eax
 8049025:       74 05                   je     804902c <level_4+0x2a>
 8049027:       e8 54 0f 00 00          call   8049f80 <explode_bomb>
 804902c:       8b 45 fc                mov    0xfffffffc(%ebp),%eax
 804902f:       89 04 24                mov    %eax,(%esp)
 8049032:       e8 ef fe ff ff          call   8048f26 <transform>
 8049037:       89 04 24                mov    %eax,(%esp)
 804903a:       e8 e7 fe ff ff          call   8048f26 <transform>
 804903f:       85 c0                   test   %eax,%eax
 8049041:       78 05                   js     8049048 <level_4+0x46>
 8049043:       e8 38 0f 00 00          call   8049f80 <explode_bomb>
 8049048:       c9                      leave  
 8049049:       c3                      ret    
 


At this point I know that sscanf takes in an integer and that integer is taken through transform. In the end of that if that integer turns out to be negative then this is solved. My question is what exactly is going on in transform. It seems to be a bunch of math being applied to the number through recursion. I'm not sure in what order. I just need some clarification or if i'm missing something that would make this a bit easier to understand.

Is This A Good Question/Topic? 0
  • +

Replies To: Clarification on recursion in assembly

#2 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,281
  • Joined: 28-March 11

Re: Clarification on recursion in assembly

Posted 19 May 2012 - 06:39 PM

We will not help you learn to reverse a program. This is code from a class or book or something. The object of the code is to figure out the correct password or number otherwise the "bomb" will explode.

*** Topic closed ***
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1