B
Bryan Parkoff
byte and word and double word are always in alignment. Do C++ Compiler
fill the zero as padding inside byte's field and word's field to avoid
misalignment? It looks like that union does not use shift which it loads
data from memory. It is like "(H << 8) | L".
Intel Pentium 4 can degrade the performance if shift is used heavily,
but union may be recommended to avoid using shift. It may be slow to store
two bytes into memory before load one word from memory containing two bytes.
union example is below.
Please advise.
union var
{
struct
{
unsigned __int8 L;
unsigned __int8 H;
};
struct
{
unsigned __int16 W;
};
};
Bryan Parkoff
fill the zero as padding inside byte's field and word's field to avoid
misalignment? It looks like that union does not use shift which it loads
data from memory. It is like "(H << 8) | L".
Intel Pentium 4 can degrade the performance if shift is used heavily,
but union may be recommended to avoid using shift. It may be slow to store
two bytes into memory before load one word from memory containing two bytes.
union example is below.
Please advise.
union var
{
struct
{
unsigned __int8 L;
unsigned __int8 H;
};
struct
{
unsigned __int16 W;
};
};
Bryan Parkoff