|
|||||||||||
|
Technical Support Support Resources
Product Information |
C251: Pointer Arithmetic Delivers Unexpected ResultsInformation in this article applies to:
QUESTIONI have found a serious problem when I use pointer arithmetic with a generic memory allocation function. The results generated seem to consider only the 16-bit offset rather than the full address space of the 251 architecture (which is up to 16MB). Why does that happen? Example:
ANSWERA pointer subtraction delivers the number of elements within an array that is addressed by these pointers. By default the C251 uses far pointers. This implies that the pointers point to the same elements within a single 64KB segment. To get the total memory that is between unrelated pointers (that point to any memory location) use an explicit cast to huge * as shown below:
Of course, a cast to DWORD will work too and is maybe more transparent to understand:
MORE INFORMATION
SEE ALSO
Last Reviewed: Thursday, February 25, 2021 | ||||||||||
|
|||||||||||
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.