汇编代码涉及比较

时间:2016-02-24 01:55:09

标签: assembly att cmp ddd-debugger

080484b4 <main>:
 80484b4:   55                      push   %ebp
 80484b5:   89 e5                   mov    %esp,%ebp
 80484b7:   57                      push   %edi
 80484b8:   53                      push   %ebx
 80484b9:   83 e4 f0                and    $0xfffffff0,%esp
 80484bc:   83 ec 40                sub    $0x40,%esp
 80484bf:   65 a1 14 00 00 00       mov    %gs:0x14,%eax
 80484c5:   89 44 24 3c             mov    %eax,0x3c(%esp)
 80484c9:   31 c0                   xor    %eax,%eax
 80484cb:   c7 44 24 20 00 00 00    movl   $0x0,0x20(%esp)
 80484d2:   00 
 80484d3:   b8 70 86 04 08          mov    $0x8048670,%eax
 80484d8:   89 04 24                mov    %eax,(%esp)
 80484db:   e8 c0 fe ff ff          call   80483a0 <printf@plt>
 80484e0:   b8 81 86 04 08          mov    $0x8048681,%eax
 80484e5:   8d 54 24 28             lea    0x28(%esp),%edx
 80484e9:   89 54 24 04             mov    %edx,0x4(%esp)
 80484ed:   89 04 24                mov    %eax,(%esp)
 80484f0:   e8 fb fe ff ff          call   80483f0 <__isoc99_scanf@plt>
 80484f5:   c7 44 24 20 00 00 00    movl   $0x0,0x20(%esp)
 80484fc:   00 
 80484fd:   eb 3f                   jmp    804853e <main+0x8a>
 80484ff:   8b 44 24 20             mov    0x20(%esp),%eax
 8048503:   05 20 a0 04 08          add    $0x804a020,%eax
 8048508:   0f b6 10                movzbl (%eax),%edx
 804850b:   8b 44 24 20             mov    0x20(%esp),%eax
 804850f:   31 d0                   xor    %edx,%eax
 8048511:   88 44 24 27             mov    %al,0x27(%esp)
 8048515:   8d 44 24 28             lea    0x28(%esp),%eax
 8048519:   03 44 24 20             add    0x20(%esp),%eax
 804851d:   0f b6 00                movzbl (%eax),%eax
 8048520:   3a 44 24 27             cmp    0x27(%esp),%al
 8048524:   74 13                   je     8048539 <main+0x85>
 8048526:   c7 04 24 84 86 04 08    movl   $0x8048684,(%esp)
 804852d:   e8 8e fe ff ff          call   80483c0 <puts@plt>
 8048532:   b8 01 00 00 00          mov    $0x1,%eax
 8048537:   eb 41                   jmp    804857a <main+0xc6>
 8048539:   83 44 24 20 01          addl   $0x1,0x20(%esp)
 804853e:   8b 5c 24 20             mov    0x20(%esp),%ebx
 8048542:   b8 20 a0 04 08          mov    $0x804a020,%eax
 8048547:   c7 44 24 1c ff ff ff    movl   $0xffffffff,0x1c(%esp)
 804854e:   ff 
 804854f:   89 c2                   mov    %eax,%edx
 8048551:   b8 00 00 00 00          mov    $0x0,%eax
 8048556:   8b 4c 24 1c             mov    0x1c(%esp),%ecx
 804855a:   89 d7                   mov    %edx,%edi
 804855c:   f2 ae                   repnz scas %es:(%edi),%al
 804855e:   89 c8                   mov    %ecx,%eax
 8048560:   f7 d0                   not    %eax
 8048562:   83 e8 01                sub    $0x1,%eax
 8048565:   39 c3                   cmp    %eax,%ebx
 8048567:   72 96                   jb     80484ff <main+0x4b>
 8048569:   c7 04 24 8b 86 04 08    movl   $0x804868b,(%esp)
 8048570:   e8 4b fe ff ff          call   80483c0 <puts@plt>
 8048575:   b8 00 00 00 00          mov    $0x0,%eax
 804857a:   8b 54 24 3c             mov    0x3c(%esp),%edx
 804857e:   65 33 15 14 00 00 00    xor    %gs:0x14,%edx
 8048585:   74 05                   je     804858c <main+0xd8>
 8048587:   e8 24 fe ff ff          call   80483b0 <__stack_chk_fail@plt>
 804858c:   8d 65 f8                lea    -0x8(%ebp),%esp
 804858f:   5b                      pop    %ebx
 8048590:   5f                      pop    %edi
 8048591:   5d                      pop    %ebp
 8048592:   c3                      ret    

I'm confused in the instruction that uses "cmp". It compares whatever is pointing to 0x27(%esp) with %eax.

However, when I try to see what is inside of 0x27(%esp) it just gives me in return a xor.

此外,%al的内容为十六进制65。 我不明白cmp在这里发生了什么。你有一个指令可以将另一条指令XOR与寄存器的值进行比较吗?结果是什么?

注意:0x414141是因为我插入了之前的scanf 3 A&#39;

0 个答案:

没有答案