反汇编三:函数传参

一、结构体拷贝传参

struct C
{
  int a;
  int b;
  int c;
};
int test()
{
  struct C st;
  st.a=1;
  st.b=2;
  st.c=3;
  printf("loccal of test ====\n");
  printf("addr st = %x\n",(&st));
  printf("addr st.a = %x\n",(&st.a));
  printf("addr st.b = %x\n",(&st.b));
  printf("addr st.c = %x\n",(&st.c));
  return test4struct(st);
} 
int test4struct(struct C st)
{
........
  printf("addr st.c = %x\n",(&st.c));
........
}

test调用test4struct
结构体的存储,先定义的(a)存低地址,后定义的(b,c)存高地址
结构体参数压栈,先定义的后压栈
在这里插入图片描述

二、引用和常引用传参

int test4struct(struct C st)
{
........
  test4structRef(st);
  return 0;
}
int  test4structRef(struct C &st)
{
	printf("structRef test ====\n");
........
	return test4conststructRef(st);
}
int  test4conststructRef(const struct C &st)
{
...........
}

通过把对象地址压栈
在这里插入图片描述

三、大结构体做形参/数组拷贝

struct big
{
  int a[10];
  int b[10];
  int c[10];
};
int  test4conststructRef(const struct C &st)
{
............
	struct big b;
	b.a[2]=2;
	b.b[3]=3;
	b.c[4]=4;
	return test4bigstruct(b);
}
int test4bigstruct(struct big b)
{
    char c[13]={"aaaaaaaa"};
......
    printf("addr big.a = %x\n",(&b.a));
    printf("addr big.b = %x\n",(&b.b));
......
	abort();
	return 0;
}

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值