I am really bad at understanding assembly code and the way it works. I have little problems given to me in Assembly code and I have to reverse engineer it to C, but I have been doing really bad job at it so far. Can someone tell me what this code translates to in C.

    .file   "hw4.c"
    .p2align 4,,15
    .globl  p1
    .type   p1, @function

    movl    (%rdi), %eax
    addl    (%rsi), %eax
    .size   p1, .-p1
    .p2align 4,,15
    .globl  p2
    .type   p2, @function
  • 5
    Welcome to RE.SE. Is this your homework? Translating asm to pseudo C is not actually reverse engineering. Start by reading on the directives in your code, flags, registers and instructions. You can't offload your homework to SE unless you show some research done/understanding. – sudhackar Oct 29 '18 at 6:06

It is just a function that perform a simple addition:

int add(int *i, int *j)
  return *i + *j;
| improve this answer | |
  • rdi and rsi are addresses to the actual numbers being added. – sudhackar Oct 30 '18 at 7:20
  • RIght. I fixed this on the code,my bad. – perror Oct 30 '18 at 9:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.