This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

typecast

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

also

  *valptr = (unsigned long) 0 ;

generates one byte of zero only

Is this Keil "exceptions" or am I doing something wrong

Thanx,

Erik


Parents
  • "should the failed attempts not have generated an error or at least a warning."

    As I've noted before, this is both the strength and the danger of pointers in 'C'!
    With pointers, the ethos of the 'C' language is very much, "you asked for it; you got it!"
    This is particularly true of embedded cross compilers, which tend to be relatively light on the amount & detail of their diagnostics.

    This is where tools like lint come in.
    Passing your code through a "big" compiler (eg, MSVC, Borland) will often elicit more detailed diagnostics.

Reply
  • "should the failed attempts not have generated an error or at least a warning."

    As I've noted before, this is both the strength and the danger of pointers in 'C'!
    With pointers, the ethos of the 'C' language is very much, "you asked for it; you got it!"
    This is particularly true of embedded cross compilers, which tend to be relatively light on the amount & detail of their diagnostics.

    This is where tools like lint come in.
    Passing your code through a "big" compiler (eg, MSVC, Borland) will often elicit more detailed diagnostics.

Children
No data