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.

MSP432E401Y: Assembly instruction SMLAxy (and some others) gives wrong result

Part Number: MSP432E401Y
Other Parts Discussed in Thread: MSP-EXP432E401Y,

Hello TI Support team.

I am having trouble with MSP432E401Y (Cortex-M4F - core). I use evaluation board MSP-EXP432E401Y, Rev. 1.0.

I write my code in Code Composer Studio 12.3.0 in assemble code.

Some instructions do not act correctly. Please, help me to find my mistakes.

Let us take instruction SMLAxy for example. Description of this instruction (from ARM DUI0473J, pg. 10-479): SMLAxy multiplies the 16-bit signed integers from the selected halves of Rn and Rm, adds the 32-bit result to the 32-bit value in Ra, and places the result in Rd.

I understand it in this way. If we use SMLATT (for example) we have:

Rd := Top_Halfword{Rn} * Top_Halfword{Rm} + Ra

First of all, look at an example without overflow. My code:

 

MOV R1,  #0x1244

MOVT R1,  #0x0229

MOV R2,  #0x3769

MOVT R2,  #0x0455

MOV R0,  #0000

MOVT R0,  #0001

SMLATT    R3, R1, R2, R0 ; After executing the instruction R3 = 0x000A5B9D

 

Compare the result with my own calculations:

Rd <= R3

Rn <= R1 := 0x02291244

Rm <= R2 := 0x04553769

Ra <= R0 := 0x00010000

Rd = THW[Rn] * THW[Rm] + Ra = 0x0229 * 0x0455 + 0x00010000 = 0x00095B9D + 0x00010000 = 0x000A5B9D, the result matches.

 

But if we take other operands, interesting results come out:

MOV R0,             #0x0001

MOVT R0,             #0xAAAA

MOV R1,             #0x000A

MOVT R1,             #0xAAAA

MOV R2,             #0x0001

MOVT R2,             #0x0060

SMLATT     R3, R1, R0, R2; After executing we have R3 = #0x1CD238E5

 

Compare with my calculation:

Rd = THW[Rn] * THW[Rm] + Ra = 0xAAAA * 0xAAAA + 0x00600001 = 0x71C638E4 + 0x00600001 = 0x722638E5, the result does not match.

The bottom halfword of the result matches, but the top halfword of the result does not match. I have no idea where this result comes from.

 

MOV R0,             #0x0001

MOVT R0,           #0xAAAA

MOV R1,             #0x000A

MOVT R1,           #0xAAAA

MOV R2,             #0 ; I want to check the multiplication only

SMLATT     R3, R1, R0, R2 ;    After executing the instruction R3 = #0x1C7238E4

 

Compare with my calculation:

Rd = THW[Rn] * THW[Rm] + Ra = 0xAAAA * 0xAAAA + 0 = 0x71C638E4, the result does not match.

 

I faced with this problem in other instructions too: SMLAD, SMLAL, SMLALxy, SMLALD, SMLAWx, SMLSLD. I have examples for all instructions.

I think, in all these instructions I did not understand some point. Please explain me, how the multiplication in these instructions acts. I would really appreciate your help.

Best regards.