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.

Asm multiplication function problem in C28X device(general programming question)

Hi all,

I am programming a basic multiplication function using asm language which is to calculate the product of the first element of two arrays. I first tried to program it by C and see what is the code after compiling, and the asm instructions and corresponding C instruction is shown below: 

  

1. In the "TMS320C28x CPU and Instruction Set Reference Guide", I saw addressing mode with sign "@" is all used with register name like "@ACC", "@ARn", and I don't know what does it mean by "@" followed by an immediate number. In line 0083c2 what register T wants to get is the content in address 0x08c13, and T got the content from address 0x008c00+0x000013=0x008c13 which is correct(0x008c00 is the start address of my RAML2). I don't quite understand how does T addressed offset from the right memory location "0x008c00"?

2. In line 0083c0, DP was loaded with #0x231 of data page. However after I watched the value and in the memory location, there's no value defined by me mapped to 0x0230 of my data page. I don't quite understand what does this #0x231 mean here therefore. My data page memory location in cmd file and memory content is shown below. Can somebody tell me about it? :) 

  

Any help is appreciated!

Doris

  • Hezi,

    The @ symbol can be read as meaning "At".  The "At" could be a register, or it could be a direct address offset on the current DP page.  I believe using the @ is optional when you code the assembly (the assembler doesn't care if you put the @ in the code line or not).  Let's take a look at the code you showed, and I've added comments:

    MOVW   DP, #0x231
    The above loads the value 0x231 into the DP. Each page is 64 words in length. So, page 0x231 corresponds to address range (0x231)*(64) = 0x8C40, and ending at 0x8C7F (0x8C40 + 64 - 1). That is in your RAML2 memory.

    MOV    T, @0x13         ;Load T with the value at address 0x8C40 + 0x13 = 0x8C53.
    MOVW   DP, #0x230       ;DP loaded for address range 0x8C00 - 0x8C3F.
    MPY    ACC, T, @0x21    ;Multiply whatever is in T with whatever is at address 0x8C00 + 0x21 = 0x8C21

    MOVU   ACC, @AL
    Load ACC with AL. This will leave AL in AL, and clear AH. The compiler is doing this because in C, a 16-bit value time a 16-bit value is a 16-bit value. The compiler clears out any overflow (the user is responsible for making sure overflow doesn't occur. The compiler does not handle this).

    MOVL   @0x14, ACC       ;Store the result to address 0x8C00 + 0x14 = 0x8C14.

    --------------------------------------

    I hope this helps you.

    David

  • Doris,

    You should read SPRU430, "TMS320C28x DSP CPU and Instruction Set Reference Guide", particularly the section "Direct Addressing Modes (DP)".  You'll see the exact syntax you have above, plus an explanation of how to interpret the data page register DP.

    Regards,

    Bill

  • Thanks Bill, I've read about that! :)
  • Thank you David! :)