标签:his operator lse 平衡 its nta return mic 等价
类>构造函数
;5 : A(int a, int b, int c) {
0x438638 push %ebp
0x438639 mov %esp,%ebp
0x43863b sub $0x4,%esp
0x43863e mov %ecx,-0x4(%ebp)
;6 : this->a = a;
0x438641 mov -0x4(%ebp),%eax
0x438644 mov 0x8(%ebp),%edx //等价于取a的值
0x438647 mov %edx,(%eax) //等价于把a赋值给类变量
;7 : this->b = b;
0x438649 mov -0x4(%ebp),%eax
0x43864c mov 0xc(%ebp),%edx
0x43864f mov %edx,0x4(%eax)
;8 : this->c = c;
0x438652 mov -0x4(%ebp),%eax
0x438655 mov 0x10(%ebp),%edx
0x438658 mov %edx,0x8(%eax)
;9 : }
0x43865b nop
0x43865c leave
0x43865d ret $0xc
类>一般方法printAll
;10 : void printAll() { 0x438598 push %ebp 0x438599 mov %esp,%ebp 0x43859b sub $0x28,%esp 0x43859e mov %ecx,-0xc(%ebp) ;11 : if(a + b > c && a + c > b && b + c > a) cout << "Yes" << endl; 0x4385a1 mov -0xc(%ebp),%eax //以下2行代码等价于为x赋值 0x4385a4 mov (%eax),%edx 0x4385a6 mov -0xc(%ebp),%eax //以下2行代码等价于为y赋值 0x4385a9 mov 0x4(%eax),%eax 0x4385ac add %eax,%edx //等价于y = x + y 0x4385ae mov -0xc(%ebp),%eax //以下2行代码等价于为z赋值 0x4385b1 mov 0x8(%eax),%eax 0x4385b4 cmp %eax,%edx //等价于y cmp z 0x4385b6 jle 0x43860d <A::printAll()+117> 0x4385b8 mov -0xc(%ebp),%eax 0x4385bb mov (%eax),%edx 0x4385bd mov -0xc(%ebp),%eax 0x4385c0 mov 0x8(%eax),%eax 0x4385c3 add %eax,%edx 0x4385c5 mov -0xc(%ebp),%eax 0x4385c8 mov 0x4(%eax),%eax 0x4385cb cmp %eax,%edx 0x4385cd jle 0x43860d <A::printAll()+117> 0x4385cf mov -0xc(%ebp),%eax 0x4385d2 mov 0x4(%eax),%edx 0x4385d5 mov -0xc(%ebp),%eax 0x4385d8 mov 0x8(%eax),%eax 0x4385db add %eax,%edx 0x4385dd mov -0xc(%ebp),%eax 0x4385e0 mov (%eax),%eax 0x4385e2 cmp %eax,%edx 0x4385e4 jle 0x43860d <A::printAll()+117> 0x4385e6 movl $0x4b9025,0x4(%esp) //以下3行代码为调用cout 0x4385ee movl $0x4c6860,(%esp) 0x4385f5 call 0x4b2ec0 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)> 0x4385fa movl $0x4b0e70,(%esp) //以下3行代码为调用endl 0x438601 mov %eax,%ecx 0x438603 call 0x47dee0 <std::ostream::operator<<(std::ostream& (*)(std::ostream&))> 0x438608 sub $0x4,%esp //平衡掉endl的栈移,因为endl不会像cout自动ret掉 0x43860b jmp 0x438632 <A::printAll()+154> ;12 : else cout << "No" << endl; 0x43860d movl $0x4b9029,0x4(%esp) 0x438615 movl $0x4c6860,(%esp) 0x43861c call 0x4b2ec0 <std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)> 0x438621 movl $0x4b0e70,(%esp) 0x438628 mov %eax,%ecx 0x43862a call 0x47dee0 <std::ostream::operator<<(std::ostream& (*)(std::ostream&))> 0x43862f sub $0x4,%esp ;13 : } 0x438632 nop 0x438633 leave 0x438634 ret
main函数
;20 : { 0x401350 lea 0x4(%esp),%ecx 0x401354 and $0xfffffff0,%esp 0x401357 pushl -0x4(%ecx) 0x40135a push %ebp 0x40135b mov %esp,%ebp 0x40135d push %ecx 0x40135e sub $0x34,%esp //开辟0x34个字节栈空间 0x401361 call 0x4270e0 <__main> ;21 : A a(3, 4, 5); 0x401366 lea -0x14(%ebp),%eax //类变量存放开始地址 0x401369 movl $0x5,0x8(%esp) //形参存放开始地址 0x401371 movl $0x4,0x4(%esp) 0x401379 movl $0x3,(%esp) 0x401380 mov %eax,%ecx //做好准备,以备在main外函数定位到类变量处 0x401382 call 0x438638 <A::A(int, int, int)> 0x401387 sub $0xc,%esp ;22 : a.printAll(); 0x40138a lea -0x14(%ebp),%eax 0x40138d mov %eax,%ecx 0x40138f call 0x438598 <A::printAll()> ;23 : A a2(1, 1, 2); 0x401394 lea -0x20(%ebp),%eax 0x401397 movl $0x2,0x8(%esp) 0x40139f movl $0x1,0x4(%esp) 0x4013a7 movl $0x1,(%esp) 0x4013ae mov %eax,%ecx 0x4013b0 call 0x438638 <A::A(int, int, int)> 0x4013b5 sub $0xc,%esp ;24 : a2.printAll(); 0x4013b8 lea -0x20(%ebp),%eax 0x4013bb mov %eax,%ecx 0x4013bd call 0x438598 <A::printAll()> ;25 : return 0; 0x4013c2 mov $0x0,%eax ;26 : } 0x4013c7 mov -0x4(%ebp),%ecx 0x4013ca leave 0x4013cb lea -0x4(%ecx),%esp 0x4013ce ret
标签:his operator lse 平衡 its nta return mic 等价
原文地址:https://www.cnblogs.com/reverse201/p/10322751.html