How to use high and low bytes? How to use high and low bytes? arrays arrays

How to use high and low bytes?


In hexadecimal, your number is 0x8000 which is 0x80 and 0x00. To get the low byte from the input, use low=input & 0xff and to get the high byte, use high=(input>>8) & 0xff.

Get the input back from the low and high byes like so: input=low | (high<<8).

Make sure the integer types you use are big enough to store these numbers. On 16-bit systems, unsigned int/short or signed/unsigned long should be be large enough.


Bytes can only contain values from 0 to 255, inclusive. 32768 is 0x8000, so the high byte is 128 and the low byte is 0.


Try this function. Pass your Hi_Byte and Lo_Byte to the function, it returns the value as Word.

WORD MAKE_WORD( const BYTE Byte_hi, const BYTE Byte_lo){     return   (( Byte_hi << 8  ) | Byte_lo & 0x00FF );}