This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR6047: What does this assembly sequence do?

Part Number: MSP430FR6047

Tool/software:

The TI compiler generates this sequence quite often that appears to do nothing and the results are always ignored (as best as I can see). Assuming, it has a good reason for generating it, I'd like to understand why this is included. I've seen it just before RETA statements as well as in the middle of functions where the output value and SR bits are completely ignored.

The two registers used vary. This tests the sign bit in r12. If set, r13 = 0xffff. If clear, r13 = 0x0000. The r13 value is never used anywhere. I've even seen CLR.W r13 as the next statement. It's always a test of 0x8000.

; r13 = 0xffff if r12 & 0x8000 else 0x0000

BIT.W     #32768,r12            ; #0x8000
SUBC.W    r13,r13
INV.W     r13

I've found this in many places in my generated assembly. Looking at the C code, I can't seem to identify the pattern that causes this assembly to be generated.

Thanks.

**Attention** This is a public forum