snake5 icon

cpp move

snake5 | PRO | 07/12/15 06:10:49 PM UTC | 0 ⭐ | 937 👁️ | Never ⏰ | []
C++ |

2.34 KB

|

None

|

0 👍

/

0 👎

g++ move.cpp -std=c++11 -c -g -m32
objdump -d -M intel -S move.o
 
/////////////////////// code
 
#include <utility>
#include <stdio.h>
 
struct foo
{
    int a, b, c, d, e;
};
 
int main()
{
    foo f1 = { 1, 2, 3, 4, 5 };
    foo f2 = std::move( f1 );
    printf( "f2.c: %d\n", f2.c );
    return 0;
}
 
/////////////////////// asm
 
00000000 <_main>:
{
        int a, b, c, d, e;
};
 
int main()
{
   0:   55                      push   ebp
   1:   89 e5                   mov    ebp,esp
   3:   83 e4 f0                and    esp,0xfffffff0
   6:   83 ec 40                sub    esp,0x40
   9:   e8 00 00 00 00          call   e <_main+0xe>
        foo f1 = { 1, 2, 3, 4, 5 };
   e:   c7 44 24 2c 01 00 00    mov    DWORD PTR [esp+0x2c],0x1
  15:   00
  16:   c7 44 24 30 02 00 00    mov    DWORD PTR [esp+0x30],0x2
  1d:   00
  1e:   c7 44 24 34 03 00 00    mov    DWORD PTR [esp+0x34],0x3
  25:   00
  26:   c7 44 24 38 04 00 00    mov    DWORD PTR [esp+0x38],0x4
  2d:   00
  2e:   c7 44 24 3c 05 00 00    mov    DWORD PTR [esp+0x3c],0x5
  35:   00
        foo f2 = std::move( f1 );
  36:   8d 44 24 2c             lea    eax,[esp+0x2c]
  3a:   89 04 24                mov    DWORD PTR [esp],eax
  3d:   e8 00 00 00 00          call   42 <_main+0x42>
  42:   8b 10                   mov    edx,DWORD PTR [eax]
  44:   89 54 24 18             mov    DWORD PTR [esp+0x18],edx
  48:   8b 50 04                mov    edx,DWORD PTR [eax+0x4]
  4b:   89 54 24 1c             mov    DWORD PTR [esp+0x1c],edx
  4f:   8b 50 08                mov    edx,DWORD PTR [eax+0x8]
  52:   89 54 24 20             mov    DWORD PTR [esp+0x20],edx
  56:   8b 50 0c                mov    edx,DWORD PTR [eax+0xc]
  59:   89 54 24 24             mov    DWORD PTR [esp+0x24],edx
  5d:   8b 40 10                mov    eax,DWORD PTR [eax+0x10]
  60:   89 44 24 28             mov    DWORD PTR [esp+0x28],eax
        printf( "f2.c: %d\n", f2.c );
  64:   8b 44 24 20             mov    eax,DWORD PTR [esp+0x20]
  68:   89 44 24 04             mov    DWORD PTR [esp+0x4],eax
  6c:   c7 04 24 01 00 00 00    mov    DWORD PTR [esp],0x1
  73:   e8 00 00 00 00          call   78 <_main+0x78>
        return 0;
  78:   b8 00 00 00 00          mov    eax,0x0
}
  7d:   c9                      leave
  7e:   c3                      ret
  7f:   90                      nop

Comments