How to Split the 16bit word?

Hi! i want to spilt the 16bit word into two 8bit words,
is there any key words for it. i use the p89V51 mcu and c language Cx51 keil compiler ver3.

regards,
K.T.Venkatesan.

Parents
  • Standard ANSI 'C' - nothing specifically to do with Keil or the 8051:

    1. Portable: use the bitwise shift & mask operators to separate the low & high 8 bits;

    2. Non-Portable: use a union of one 16-bit type and two 8-bit types;

    3. Non-Portable: Use a pointer to point at the low & high bytes.

    The 2nd two are non-portable because they rely upon the byte ordering used by the specific compiler;

    The union is likely to be the fastest.

Reply
  • Standard ANSI 'C' - nothing specifically to do with Keil or the 8051:

    1. Portable: use the bitwise shift & mask operators to separate the low & high 8 bits;

    2. Non-Portable: use a union of one 16-bit type and two 8-bit types;

    3. Non-Portable: Use a pointer to point at the low & high bytes.

    The 2nd two are non-portable because they rely upon the byte ordering used by the specific compiler;

    The union is likely to be the fastest.

Children
More questions in this forum