Explanation of Undesired Behaviors

If “SCICR” is mapped to a peripheral register, the code that is used to access the register is not portable and might be unsafe, like in DSP56800E at present.

Bit field behavior in C is almost all implementation defined. So generating the following code is legal:

     SCICR.Bits.TE = 1;            /* SCICR content is 0x0800 */



/* generated codes

P:00000082:874802c     moveu.w     #SCICR,R0

P:00000084:F0E0000     move.b      X:(R0),A

P:00000086:8350008     bfset       #8,A1

P:00000088:9800        move.b      A1,X:(R0)

*/



     SCICR.Bits.PE = 1;     /* SCICR content is 0x0002 ??? */



/* generated codes

P:00000089:F0E00001    move.b      X:(R0+1),A

P:0000008B:83500002    bfset       #2,A1

P:0000008D:9804        move.b      A1,X:(R0+1)

*/

However, since the writes (at P:0x88 and at P:0x8D) are byte instructions and only 16 bits can be written to the SCICR register, the other bytes look as if they are filled with zeros before the SCICR is overwritten.

The use of byte accesses is due to a compiler optimization that tries to generate the smallest possible memory access.