kohlrak

Untitled

Jul 17th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. C++:
  2.  
  3. int add(int x, int y){
  4.         return x+y;
  5. }
  6.  
  7. g++ output (default):
  8.  
  9.         .globl  _Z3addii
  10.         .type   _Z3addii, @function
  11. _Z3addii:
  12. .LFB0:
  13.         .cfi_startproc
  14.         push    ebp
  15.         .cfi_def_cfa_offset 8
  16.         .cfi_offset 5, -8
  17.         mov     ebp, esp
  18.         .cfi_def_cfa_register 5
  19.         mov     edx, DWORD PTR [ebp+8]
  20.         mov     eax, DWORD PTR [ebp+12]
  21.         add     eax, edx
  22.         pop     ebp
  23.         .cfi_restore 5
  24.         .cfi_def_cfa 4, 4
  25.         ret
  26.         .cfi_endproc
  27.  
  28. g++ output (formatting functions removed):
  29.  
  30. _Z3addii: #leaving this here, even though it won't end up in the binary, since i would type it, too.
  31.        push    ebp
  32.        mov     ebp, esp
  33.        mov     edx, DWORD PTR [ebp+8]
  34.        mov     eax, DWORD PTR [ebp+12]
  35.        add     eax, edx
  36.        pop     ebp
  37.        ret
  38.  
  39. g++ output (formatting removed, optimization to maximum):
  40. _Z3addii:
  41.        mov     eax, DWORD PTR [esp+8]
  42.        add     eax, DWORD PTR [esp+4]
  43.        ret
  44.  
  45. my handwritten assembly:
  46. _Z3addii:
  47.     mov eax, [esp+4]
  48.     add eax, [esp+8]
  49.     ret
Advertisement
Add Comment
Please, Sign In to add comment