#include"stdafx.h"structperson{intage;intsex;charname[20];
};structperson GetPerson(intage,intsex,char*name)
{structperson p;
p.age=age;
p.sex=sex;
strcpy(p.name,name);returnp;
}intmain()
{intm=0x7ffff123;intn=0x7ffff456;intk=0x7fffffff;//汇编指令:imul,mullonglongx=(longlong)(m*n);//返回值类型为 int,然后强制转换为long long,最后赋值给x,longlongy=(longlong)m*n;//返回值类型为 long long,然后赋值给y,注意强制类型转换括号的位置,longlongz=m*n;//返回值类型为 int,然后赋值给x./*汇编指令:
004114BC mov eax,dword ptr [m]
004114BF imul eax,dword ptr [n]
004114C3 cdq //数据扩展指令,将双字数据扩展为四字类型
//CDQ—Convert Double to Quad (386+),该指令把edx扩展为eax的高位,也就是说变为64位。
004114C4 mov dword ptr [z],eax
004114C7 mov dword ptr [ebp-4Ch],edx*/printf("m = %d,n = %d \n",m,n);
printf("x = %lld\n",x);
printf("y = %lld\n",y);
printf("z = %lld\n",z);intm1=8;intn1=3;intk1=m1/n1;doublek2=m1/n1;//返回值类型为 int,然后赋值给k2,汇编指令:idiv/*汇编指令:
0041155E mov eax,dword ptr [m1]
00411561 cdq
00411562 idiv eax,dword ptr [n1]
00411565 mov dword ptr [ebp-1F4h],eax
0041156B fild dword ptr [ebp-1F4h]
00411571 fstp qword ptr [k2]
fild和fstp都是x87指令
fild浮点加载整数 然后转换为长双精度
fild是将整数转化为长双精FP80压栈(压到st0),
fstp是将弹栈指令,将st0弹出。*/doublek3=(double)(m1/n1);//返回值类型为 int,然后强制转换为double,最后赋值给k3,汇编指令:idivdoublek4=(double)m1/n1;//返回值类型为double,然后赋值给k4,注意强制类型转换括号的位置,汇编指令:fidiv/*汇编指令:
00411590 fild dword ptr [m1]
00411593 fidiv dword ptr [n1]
00411596 fstp qword ptr [k4]*/printf("k1=%d \r\n",k1);
printf("k2=%f \r\n",k2);
printf("k3=%f \r\n",k3);
printf("k4=%f \r\n",k4);charl1=127;charl2=122;intl3=l1*l2;/*汇编指令:
0041162E movsx eax,byte ptr [l1]
00411635 movsx ecx,byte ptr [l2]
0041163C imul eax,ecx
0041163F mov dword ptr [l3],eax*/charl4=l1*l2;/*汇编指令:
00411645 movsx eax,byte ptr [l1]
0041164C movsx ecx,byte ptr [l2]
00411653 imul eax,ecx
00411656 mov byte ptr [l4],al*/intl5=l1/l2;intl6=double(l1)/l2;longdoublek5=l1*l2;/*汇编指令:
004116A6 movsx eax,byte ptr [l1]
004116AD movsx ecx,byte ptr [l2]
004116B4 imul eax,ecx
004116B7 mov dword ptr [ebp-1F4h],eax
004116BD fild dword ptr [ebp-1F4h]
004116C3 fstp qword ptr [k5]*/printf("l3=%d \r\n",l3);
printf("l4=%d \r\n",l4);
printf("k4=%lf \r\n",k5);longlongo1=0xff34567812345677;longlongo2=0xab34567834125615;longlongo3=o1*o2;//溢出intage=5;intsex=1;charname[20]="Aaron";structperson p1={5,1,"Aaron"};structperson p2;structperson*pp1=&p1;structperson*pp2=&p2;
p2=p1;/*汇编指令:
00414348 mov ecx,7
0041434D lea esi,[ebp-188h]
00414353 lea edi,[ebp-1ACh]
00414359 rep movs dword ptr es:[edi],dword ptr [esi]
//ecx 是计数器(counter),是重复(REP)前缀指令和LOOP指令的内定计数器。
因为sizeof(person) = 28,所以才有mov ecx,7*/structperson p3;
p3=GetPerson(age,sex,name);//结论:/*整数类型:
小于等于4字节的返回值放在eax中,
8字节的返回值放在edx + eax中,其中edx为高位,eax为低位.
浮点数类型:
计算是通过压栈的方式,如汇编指令:fild
返回是通过出栈的方式,如汇编指令:fstp
结构体类型赋值:
是通过内存拷贝的方式,如汇编指令:rep movs
将源值的地址放入esi,
将目标值的地址放入edi,
00414393 lea esi,[ebp-2D8h]
00414399 lea edi,[ebp-1D0h]
0041439F rep movs dword ptr es:[edi],dword ptr [esi]
结构体类型返回值:
通过eax将结构体的指针返回*/system("pause");return0;
}//111111111111111111111111111111//00000000000000000000000000000001111111111111111111001010111100//10000000101011010101110111000010//取反加一 1111111010100101010001000111110//11111001111111111111111111111110000011000//11111111111111111111110000011000//1111101000//11111010000000000000000000000000000000000 = 0//000000000000000000000000000000001111111111111111111110000011000