类作为参数传递
main函数;17 : {0x401373 lea 0x4(%esp),%ecx0x401377 and $0xfffffff0,%esp0x40137a pushl -0x4(%ecx)0x40137d push %ebp0x40137e mov %esp,%ebp0x401380 push %ecx0x401381 sub $0x24,%esp0x401384 call 0x4270d0 <__main>;18 : A a(3, 4);0x401389 lea -0x10(%ebp),%eax0x40138c movl $0x4,0x4(%esp)0x401394 movl $0x3,(%esp)0x40139b mov %eax,%ecx0x40139d call 0x4385c0 <A::A(int, int)>0x4013a2 sub $0x8,%esp;19 : printAll(a);0x4013a5 mov -0x10(%ebp),%eax //此处赋值后eax = 30x4013a8 mov -0xc(%ebp),%edx //此处赋值后edx = 40x4013ab mov %eax,(%esp) 0x4013ae mov %edx,0x4(%esp)0x4013b2 call 0x401350 <printAll(A)>;20 : return 0;0x4013b7 mov $0x0,%eax;21 : }0x4013bc mov -0x4(%ebp),%ecx0x4013bf leave0x4013c0 lea -0x4(%ecx),%esp0x4013c3 ret
类>构造函数 ;7 : A(int a, int b) { 0x4385c0 push %ebp 0x4385c1 mov %esp,%ebp 0x4385c3 sub $0x4,%esp 0x4385c6 mov %ecx,-0x4(%ebp) ;8 : this->a = a; 0x4385c9 mov -0x4(%ebp),%eax 0x4385cc mov 0x8(%ebp),%edx 0x4385cf mov %edx,(%eax) ;9 : this->b = b; 0x4385d1 mov -0x4(%ebp),%eax 0x4385d4 mov 0xc(%ebp),%edx 0x4385d7 mov %edx,0x4(%eax) ;10 : } 0x4385da nop 0x4385db leave 0x4385dc ret $0x8
带对象参的方法printAll ;13 : void printAll(A a) { 0x401350 push %ebp 0x401351 mov %esp,%ebp 0x401353 sub $0x18,%esp ;14 : printf("%d,%d\n", a.a, a.b); 0x401356 mov 0xc(%ebp),%edx //此处赋值后edx = 4 0x401359 mov 0x8(%ebp),%eax //此处赋值后eax = 3 0x40135c mov %edx,0x8(%esp) 0x401360 mov %eax,0x4(%esp) 0x401364 movl $0x4b9025,(%esp) 0x40136b call 0x4b5850 <printf(char const*, ...)> ;15 : } 0x401370 nop 0x401371 leave 0x401372 ret
原文地址:https://www.cnblogs.com/reverse201/p/10325339.html
时间: 2024-10-16 01:03:00