Hi, in v1.40 there are apparently still problems when manipulating (setting/resetting) a bit from a byte when the bitnumber is a variable. The problems do not occur when the bitnumber is a literal.
e.g.:
Code: Select all
var I, J: byte;
...
I := %01010101; // bit 2 is "1", bit 3 = "0"
J := 2;
I.J := not I.J; // does not work (resetting a bit does not work?)
I.J := not I.J; // does not work
J := 3;
I.J := not I.J; // OK, setting a bit does work
I.J := not I.J; // does not work
Code: Select all
var I, J: byte;
...
I := %01010101;
J := 3;
I.J := 1; // results in I=%00001000 (only bit 3 set, all others cleared)
I.J := 0; // results in I=%00000000 (all bits reset)
Code: Select all
var I, J: byte;
...
I := %01010101;
J := 3;
SetBit(I, J); // results in I=%00001000 (only bit 3 set, all others cleared)
ClearBit(I, J); // results in I=%00000000 (all bits reset)
Thanks in advance!
p.s. code was compiled for P16F877A
(**)
[erratum 20-4-2009]
Apparently the reason why the items marked with "(**)" give a wrong result is the declaration of a "bit" variable (that was not used furtheron) just before the declaration of I and J:
Code: Select all
var Bt: bit; // <--- this one
I, J: byte;
[/erratum]