tom12sg
Member level 2
Hi,
Sorry, if this is very fundamental. I just can't figure out...
I wish to shift a bytes to the left of a continuous 3 bytes, so I try this:
I'm not caring about little-ending of big-ending at this monent.
struct{
unsigned char val_hi;
unsigned char val_mid;
unsigned char val_lo;
}mix;
void shift_byte(unsigned char val)
{
mix.val_mid<<=8; //expect last value to move to hi
mix.val_lo <<=8; //expect last value to move to mid
mix.val_lo = val; //insert new value
}
main()
{
shift_byte(0x24);
shift_byte(0x79);
shift_byte(0x03);
//Wanted expected output: val_hi=0x24
// val_mid=0x79
// val_lo=0x03
}
How should the shifting be accompanish??
Please help. Thanks.
Sorry, if this is very fundamental. I just can't figure out...
I wish to shift a bytes to the left of a continuous 3 bytes, so I try this:
I'm not caring about little-ending of big-ending at this monent.
struct{
unsigned char val_hi;
unsigned char val_mid;
unsigned char val_lo;
}mix;
void shift_byte(unsigned char val)
{
mix.val_mid<<=8; //expect last value to move to hi
mix.val_lo <<=8; //expect last value to move to mid
mix.val_lo = val; //insert new value
}
main()
{
shift_byte(0x24);
shift_byte(0x79);
shift_byte(0x03);
//Wanted expected output: val_hi=0x24
// val_mid=0x79
// val_lo=0x03
}
How should the shifting be accompanish??
Please help. Thanks.