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

what's wrong ? why?

#include "reg51.h"
main()
{
bit k;
k = ACC^7; //this instruction is right .
ACC^7 = 1; // this instruction is wrong! why?
}


thank you !

Parents
  • Neither of your statements does what you intend...

    The "^" character only means "bit position" within an sbit declaration. Everywhere else it has its standard C meaning, which is the exclusive OR operator.
    So "k = ACC^7;" means
    take the ACC register, XOR it with 7, then truncate the 8 bit result to one bit and place into k".
    "ACC^7 = 1;" is a nonsense statement in C terms.

Reply
  • Neither of your statements does what you intend...

    The "^" character only means "bit position" within an sbit declaration. Everywhere else it has its standard C meaning, which is the exclusive OR operator.
    So "k = ACC^7;" means
    take the ACC register, XOR it with 7, then truncate the 8 bit result to one bit and place into k".
    "ACC^7 = 1;" is a nonsense statement in C terms.

Children