I just have two bitfields and I want to copy the state of one bit from the first bitfield into a bit of the second one:
Flags2.bit0 = Flags1.bit1;
in assembler I get following code:
008845: 1825FFFE AND @0x25, #0xfffe
008847: 761F021B MOVW DP, #0x21b
008849: CC280002 AND AL, @0x28, #0x2
00884b: 761F0218 MOVW DP, #0x218
00884d: FFC0 LSR AL, 1
00884e: 9825 OR @0x25, AL
The destination bit is first cleared and then written with the source value.
Now I have the problem that the destination bit can be read in a interrupt routine as 0 instead of 1!
How should I change my code so that the bitfield is written just ones and directly with the rigth value? i.e.
00882b: 9326 MOV AH, @0x25
00882c: 761F021B MOVW DP, #0x21b
008830: CC280002 AND AL, @0x28, #0x2
008831: 18A8FFFE AND @AH, #0xfffe
008834: CBA9 OR AH, @AL
00883d: 9726 MOV @0x25, AH
Thanks a lot!
Luca