Hello ARM 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.
Previously I have posted my request to Texas Instruments support forum, but they answer me: “Please consult with Arm support forum for guidance”.
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 R2, #0 ; I want to check the multiplication only
SMLATT R3, R1, R0, R2 ; After executing the instruction R3 = #0x1C7238E4
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 do not understand some point. Please explain me, how the multiplication in these instructions acts. I would really appreciate your help.
Best regards.
Evgen,
You are not taking into account the sign bit.
0xAAAA is -21846, not +43690.
https://developer.arm.com/documentation/ddi0403/d/Application-Level-Architecture/Instruction-Details/Alphabetical-list-of-ARMv7-M-Thumb-instructions/SMLABB--SMLABT--SMLATB--SMLATT
Regards, Ronan
Hello Ronan,
Thank you very much for the reply. The answer is much simpler, than I thought. Later I will check other instructions.