Advertisement
snake5

cpp move

Jul 12th, 2015
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.34 KB | None | 0 0
  1. g++ move.cpp -std=c++11 -c -g -m32
  2. objdump -d -M intel -S move.o
  3.  
  4. /////////////////////// code
  5.  
  6. #include <utility>
  7. #include <stdio.h>
  8.  
  9. struct foo
  10. {
  11.     int a, b, c, d, e;
  12. };
  13.  
  14. int main()
  15. {
  16.     foo f1 = { 1, 2, 3, 4, 5 };
  17.     foo f2 = std::move( f1 );
  18.     printf( "f2.c: %d\n", f2.c );
  19.     return 0;
  20. }
  21.  
  22. /////////////////////// asm
  23.  
  24. 00000000 <_main>:
  25. {
  26.         int a, b, c, d, e;
  27. };
  28.  
  29. int main()
  30. {
  31.    0:   55                      push   ebp
  32.    1:   89 e5                   mov    ebp,esp
  33.    3:   83 e4 f0                and    esp,0xfffffff0
  34.    6:   83 ec 40                sub    esp,0x40
  35.    9:   e8 00 00 00 00          call   e <_main+0xe>
  36.         foo f1 = { 1, 2, 3, 4, 5 };
  37.    e:   c7 44 24 2c 01 00 00    mov    DWORD PTR [esp+0x2c],0x1
  38.   15:   00
  39.   16:   c7 44 24 30 02 00 00    mov    DWORD PTR [esp+0x30],0x2
  40.   1d:   00
  41.   1e:   c7 44 24 34 03 00 00    mov    DWORD PTR [esp+0x34],0x3
  42.   25:   00
  43.   26:   c7 44 24 38 04 00 00    mov    DWORD PTR [esp+0x38],0x4
  44.   2d:   00
  45.   2e:   c7 44 24 3c 05 00 00    mov    DWORD PTR [esp+0x3c],0x5
  46.   35:   00
  47.         foo f2 = std::move( f1 );
  48.   36:   8d 44 24 2c             lea    eax,[esp+0x2c]
  49.   3a:   89 04 24                mov    DWORD PTR [esp],eax
  50.   3d:   e8 00 00 00 00          call   42 <_main+0x42>
  51.   42:   8b 10                   mov    edx,DWORD PTR [eax]
  52.   44:   89 54 24 18             mov    DWORD PTR [esp+0x18],edx
  53.   48:   8b 50 04                mov    edx,DWORD PTR [eax+0x4]
  54.   4b:   89 54 24 1c             mov    DWORD PTR [esp+0x1c],edx
  55.   4f:   8b 50 08                mov    edx,DWORD PTR [eax+0x8]
  56.   52:   89 54 24 20             mov    DWORD PTR [esp+0x20],edx
  57.   56:   8b 50 0c                mov    edx,DWORD PTR [eax+0xc]
  58.   59:   89 54 24 24             mov    DWORD PTR [esp+0x24],edx
  59.   5d:   8b 40 10                mov    eax,DWORD PTR [eax+0x10]
  60.   60:   89 44 24 28             mov    DWORD PTR [esp+0x28],eax
  61.         printf( "f2.c: %d\n", f2.c );
  62.   64:   8b 44 24 20             mov    eax,DWORD PTR [esp+0x20]
  63.   68:   89 44 24 04             mov    DWORD PTR [esp+0x4],eax
  64.   6c:   c7 04 24 01 00 00 00    mov    DWORD PTR [esp],0x1
  65.   73:   e8 00 00 00 00          call   78 <_main+0x78>
  66.         return 0;
  67.   78:   b8 00 00 00 00          mov    eax,0x0
  68. }
  69.   7d:   c9                      leave
  70.   7e:   c3                      ret
  71.   7f:   90                      nop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement