Issues with Comparing the Value of a RAM Variable in C – KBA96489

Version: **



Compare instructions do not work correctly with the variable value in C. The RAM variable is defined with the #define directive, such as this: #define StackTop (* (int*) 0x7fe). It is possible to read/modify the value of the variable in the C code correctly.



Answer: This is a known ImageCraft compiler issue.

If the variable is defined as #define StackTop (* (int*) 0x7fe), modification and read operations work correctly as follows:


StackTop = 0x1234;

Variable read:

int i;

i = StackTop; // i = 0x1234;

However, the following compare instruction does not operate correctly:

If (StackTop == 0x1234) {}

To resolve the issue, see the Knowledge Base article: Allocation of Variables at Absolute Address in RAM