To the best of my knowledge the 'if' below should test 2 bytes. What is wrong here
void funct(unsigned char *valptr) { if (((unsigned int)*valptr) != 0) generates 0012 8F82 MOV DPL,R7 0014 8E83 MOV DPH,R6 0016 E0 MOVX A,@DPTR 0017 60F9 JZ ?C0047
*valptr = (unsigned long) 0 ;
The generated code is perfectly correct. In the first example, the condition is true if (*valptr) is nonzero, whether you convert it to unsigned int or not. The compiler is right here. The second example is essentially about the same thing. Regards, Mike
Sorry, the second example is not about the same thing. In an assignment, the value of the right operand is converted to the type of the left expression. So nothing unusual here as well. - Mike
View all questions in Keil forum