assembly - Why do I only need to increment for change a asm instruction using hexa editor -


i'm trying modify program , display "it's not same" using objdump , hexadecimal editor.

#include <string.h> #include <stdio.h>  int     main(int argc, char *argv[]) {   int   return_value;    return_value = strcmp("test", "test");   if (return_value == 0)       printf("it's same\n")   else       printf("it's not same\n");   return (1); } 

do used objdump -d , found line of jne instruction. first question know jne instruction , why not je ? because jne mean "jump not equal" wrote in condition if return value equal 0.

my second question in title, why need increment change instruction ? (as in following link)

how 1 change instruction hex editor?

  400526:       55                      push   %rbp   400527:       48 89 e5                mov    %rsp,%rbp   40052a:       48 83 ec 20             sub    $0x20,%rsp   40052e:       89 7d ec                mov    %edi,-0x14(%rbp)   400531:       48 89 75 e0             mov    %rsi,-0x20(%rbp)   400535:       c7 45 fc 00 00 00 00    movl   $0x0,-0x4(%rbp)   40053c:       83 7d fc 00             cmpl   $0x0,-0x4(%rbp)   400540:       75 0c                   jne    40054e <main+0x28>   400542:       bf e4 05 40 00          mov    $0x4005e4,%edi   400547:       e8 b4 fe ff ff          callq  400400 <puts@plt>   40054c:       eb 0a                   jmp    400558 <main+0x32>   40054e:       bf f1 05 40 00          mov    $0x4005f1,%edi   400553:       e8 a8 fe ff ff          callq  400400 <puts@plt>   400558:       b8 01 00 00 00          mov    $0x1,%eax   40055d:       c9                      leaveq   40055e:       c3                      retq   40055f:       90                      nop 

i replace 75 76 in hexa editor , worked. didn't understand why. (and way, 0c corresponding ?)

thanks

@michael explained in comment why/how jne being used.

as increment part of question: happens binary encodings (a.k.a. machine language) of original , changed instructions 1 apart.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -