Keil Logo

C51: XWORD MACRO QUESTIONS


Information in this article applies to:

  • C51 All Versions

QUESTION

When using the XBYTE MACRO, my data is stored exactly where it is supposed to be. All works OK. When I use the XWORD MACRO, the data does not go to the specified address.

What's happening here?

ANSWER

The XBYTE macro is defined to access memory as a large array of unsigned char. For example:

xdata unsigned char XBYTE [0x10000] _at_ 0;

The XWORD macro is defined to access memory as a large array of unsigned int. For example:

xdata unsigned int XWORD [0x8000] _at_ 0;

XBYTE[100] accesses the BYTE at address 100. While XWORD[100] accesses the WORD at address 200.

In a nutshell, the XWORD macro only accesses 16-bit values on even boundaries. The index is NOT the address, but the index of the word. The address is 2 times the index. This is the same as indexing into an array of ints that start at address 0.

MORE INFORMATION

  • Refer to XBYTE in the Cx51 User's Guide.
  • Refer to XWORD in the Cx51 User's Guide.

SEE ALSO

Last Reviewed: Friday, July 15, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.