// 测试2平台的 byte order, 经实测的结果见注释:供 porting code 分析参考
// x86 platform
#include "stdafx.h"
#include "stdio.h"
int main(int argc, char* argv[])
{
long int str[2] = {0x41424344, 0x0}; /* ASCII "ABCD" */
struct
{
unsigned short y;
unsigned short x;
} p;
p.x = 0x1234;
p.y = 0x5678;
unsigned long *lparam,a;
lparam = (unsigned long *)&p;
a = *lparam;
printf ("%s\n", (char *)&str); // x86 : "DCBA" PowerPc: "ABCD"
printf ("%0x\n", a); // x86 : 12345678 (打印并非按内存次序)
printf ("%0x\n", *((char*)&a+1)); // x86 : 56
// powerpc: "ABCD"
// powerpc: 56781234
// powerpc: 78
// x86: PowerPc
// &a 内存分配 78 56 34 12 56 78 12 34
// &p 内存分配 78 56 34 12
return 0;
}
/*--------*/
/* PowerPC application test */
#include "stdio.h"
#include <sysLib.h>
#include <vxWorks.h>
#include <taskLib.h>
void t1()
{
long int str[2] = {0x41424344, 0x0}; // ASCII "ABCD"
struct
{
unsigned short y;
unsigned short x;
} p;
p.x = 0x1234;
p.y = 0x5678;
unsigned long *lparam,a;
lparam = (unsigned long *)&p;
a = *lparam;
printf ("%s\n", (char *)&str);
printf ("%0x\n", a);
}
int t2()
{
long id;
id= taskSpawn("abc",120,VX_FP_TASK,20000,(FUNCPTR)t1,
0,0,0,0,0,0,0,0,0,0);
return 0;
}