以下使用代码对相关变量来进行说明
void vReceive(uint8 *tamo)
{
tamo[0]=0xa0;
tamo[1]=0xa1;
tamo[2]=0xa2;
}
temp=0x11223344;
*((uint8 *)&temp+3) = 0x55;
*((uint8 *)&temp+2) = 0x66;
*((uint8 *)&temp+1) = 0x77;
*((uint8 *)&temp) =0x88;
vReceive((uint8 *)&temp);
*((uint8 *)&temp2+3) = *((uint8*)&temp);
*((uint8 *)&temp2+2) = *((uint8 *)&temp+1);
*((uint8*)&temp2+1) = *((uint8*)&temp+2);
*((uint8 *)&temp2) = *((uint8*)&temp+3);
对以上的程序分别在keil和vc中调试查看变量
keil中:(keil中叶不完全是下面的结果,主要还是看cpu执行的是大端在前还是小端在前)
1 初始 temp=0x11223344
2 执行以下后 temp=0x88776655
*((uint8 *)&temp+3) = 0x55;
*((uint8 *)&temp+2) = 0x66;
*((uint8 *)&temp+1) = 0x77;
*((uint8 *)&temp) =0x88;
3 执行vReceive((uint8 *)&temp); 后 temp=0xa0a1a255
4 执行以下代码后 temp2=0x55a2a1a0
*((uint8 *)&temp2+3) = *((uint8*)&temp);
*((uint8 *)&temp2+2) = *((uint8 *)&temp+1);
*((uint8*)&temp2+1) = *((uint8*)&temp+2);
*((uint8 *)&temp2) = *((uint8*)&temp+3);
VC中:
1 初始 temp=0x11223344
2 执行以下后 temp=0x55667788
*((uint8 *)&temp+3) = 0x55;
*((uint8 *)&temp+2) = 0x66;
*((uint8 *)&temp+1) = 0x77;
*((uint8 *)&temp) =0x88;
3 执行vReceive((uint8 *)&temp); 后 temp=0x55a2a1a0
4 执行以下代码后 temp2=0xa0a1a255
*((uint8 *)&temp2+3) = *((uint8*)&temp);
*((uint8 *)&temp2+2) = *((uint8 *)&temp+1);
*((uint8*)&temp2+1) = *((uint8*)&temp+2);
*((uint8 *)&temp2) = *((uint8*)&temp+3);