0

So I have the following Assembly Function:

00000000004005d0 <sumsum>:
  4005d0: 41 55                 push   %r13
  4005d2: 41 54                 push   %r12
  4005d4: 55                    push   %rbp
  4005d5: 53                    push   %rbx
  4005d6: 41 89 d5              mov    %edx,%r13d
  4005d9: 41 89 cc              mov    %ecx,%r12d
  4005dc: 44 89 c5              mov    %r8d,%ebp
  4005df: 44 89 cb              mov    %r9d,%ebx
  4005e2: 8b 36                 mov    (%rsi),%esi
  4005e4: e8 c7 ff ff ff        callq  4005b0 <sum>
  4005e9: 44 01 e8              add    %r13d,%eax
  4005ec: 44 01 e0              add    %r12d,%eax
  4005ef: 01 e8                 add    %ebp,%eax
  4005f1: 01 d8                 add    %ebx,%eax
  4005f3: 03 44 24 28           add    0x28(%rsp),%eax
  4005f7: 48 8b 54 24 30        mov    0x30(%rsp),%rdx
  4005fc: 0f bf 12              movswl (%rdx),%edx
  4005ff: 29 d0                 sub    %edx,%eax
  400601: 5b                    pop    %rbx
  400602: 5d                    pop    %rbp
  400603: 41 5c                 pop    %r12
  400605: 41 5d                 pop    %r13
  400607: c3                    ret

Am I correct in thinking that the Parameters of said function are the ones pushed, because the parameters are stored on the stack ? Or am I gravely mistaken ?

Kennitala
  • 3
  • 3
  • 1
    depending on calling convention - arguments can be passed in registers as well https://en.wikipedia.org/wiki/X86_calling_conventions#x86-64_calling_conventions – Iłya Bursov Oct 06 '22 at 19:13
  • In this case you can deduce that those pushes are for preserving what's there from the corresponding pops before the final return. – 500 - Internal Server Error Oct 06 '22 at 19:15
  • Assuming this is one of the two standard x86-64 calling conventions (and not a minor modification to one of them), we can tell this is x86-64 System V, because RSI is being used as an input. And that it's not reserving shadow space for the call to `sumsum`. Interestingly, the 4 arg registers it copies to call-preserved regs are the same 4 registers that Windows x64 uses for arg passing, but x86-64 SysV passes the first 2 in RDI and RSI. – Peter Cordes Oct 06 '22 at 19:19

0 Answers0