0

I just started assembly, so i'm having a hard time understanding

This is a full assembly code of function F1

Dump of assembler code for function F1:
   0x000000000000114a <+0>:     push   %rbp
   0x000000000000114b <+1>:     push   %rbx
   0x000000000000114c <+2>:     sub    $0x8,%rsp
   0x0000000000001150 <+6>:     mov    %edi,%ebx
   0x0000000000001152 <+8>:     test   %edi,%edi
   0x0000000000001154 <+10>:    je     0x115b <F1+17>
   0x0000000000001156 <+12>:    cmp    $0x1,%edi
   0x0000000000001159 <+15>:    jne    0x1164 <F1+26>
   0x000000000000115b <+17>:    mov    %ebx,%eax
   0x000000000000115d <+19>:    add    $0x8,%rsp
   0x0000000000001161 <+23>:    pop    %rbx
   0x0000000000001162 <+24>:    pop    %rbp
   0x0000000000001163 <+25>:    retq
   0x0000000000001164 <+26>:    lea    -0x1(%rdi),%edi
   0x0000000000001167 <+29>:    callq  0x114a <F1>
   0x000000000000116c <+34>:    mov    %eax,%ebp
   0x000000000000116e <+36>:    lea    -0x2(%rbx),%edi
   0x0000000000001171 <+39>:    callq  0x114a <F1>
   0x0000000000001176 <+44>:    lea    0x0(%rbp,%rax,1),%ebx
   0x000000000000117a <+48>:    jmp    0x115b <F1+17>
End of assembler dump.

this part is where i want to know

   0x000000000000114a <+0>:     push   %rbp
   0x000000000000114b <+1>:     push   %rbx
   0x000000000000114c <+2>:     sub    $0x8,%rsp

I know that %rsp is a pointer pointing to the top position on the stack, but I gave rbp a value from <+0> to push %rbp, but %rsp did not.

Did you automatically change %rsp to a pointer to %rbx because of push %rbx on <+1>?

tklee
  • 1

0 Answers0