User`s guide

Developing an Application [3]
Example 2. Retrieving a condition code and result of a previous operation
It is also possible to test the condition code generated by some earlier operation,
allowing you to make use of both the condition code and the result of the operation.
In the following example,
MTA_TEST_CC is used to test whether there was a carry
generated by MTA_BIT_LEFT_ZEROS. MTA_BIT_LEFT_ZEROS returns the
number of consecutive 0 bits on the left end of the word.
enum{IF_CY = 16+32+64+128};
const int j = MTA_BIT_LEFT_ZEROS(i);
if(MTA_TEST_CC(j, IF_CY))
{
printf("i was zero\n");
}
else
{
printf("i had %d significant zeros\n", j);
}
Example 3. Retrieving a condition code set by a previous operation
The operation that sets the condition code does not need to be an intrinsic function.
The condition code is usually set by an ordinary addition or multiplication operation,
such as the following.
enum{IF_CY = 16+32+64+128};
const int k = i + j;
if(MTA_TEST_CC(k, IF_CY))
{
printf("carry generated\n");
}
If the expression is more complex, the condition code is only available from the last
operation. For example, the expression in the following example requires two adds
but only the second add affects the condition code. Because the compiler can evaluate
this code in three different ways, it may not yield the correct result.
enum{IF_CY = 16 + 32 + 64 + 128};
const int m = i + j + k;
if(MTA_TEST_CC(m, IF_CY))
{
printf("carry generated\n");
}
S247920 35