Haodong Wang wrote:

Hi,

Sometime I have a strange problem when I do jump in my assembly code (embedded in C), the compiler always complains "Error: symbol 'L1' is already defined". I changed the symbol, but it still complains the same problem. Is that the bug in mspgcc? Any solution to get around? Thanks!

"       mov #1000, r8   \n"
"L1:                            \n"
"       mov #1000, r9   \n"
......
"       jnz L1                \n"
haodong

Defining L1 creates a symbol in the assembly language code with a fixed name. If you do that more than once you will get an error tht the symbol is already defined. If you try something like the following that doesn't happen, as the actual names of the labels are generated dynamically (I just grabbed a suitable example from my own source code. This does an efficient Q1.15 multiply for machines with no hardware multiplier).

Steve

   __asm__ (
       " tst    %[x] \n"
       " jge    2f \n"
       " mov    #-1,%[x1] \n"
       " jmp    2f \n"
       "6: \n"
       " add    %[x],%A[z] \n"
       " addc     %[x1],%B[z] \n"
       "1: \n"
       " rla    %[x] \n"
       " rlc    %[x1] \n"
       "2: \n"
       " rra    %[y] \n"
       " jc    5f \n"
       " jne    1b \n"
       " jmp    4f \n"
       "5: \n"
       " sub    %[x],%A[z] \n"
       " subc     %[x1],%B[z] \n"
       "3: \n"
       " rla    %[x] \n"
       " rlc    %[x1] \n"
       " rra    %[y] \n"
       " jnc    6b \n"
       " cmp    #0xFFFF,%[y] \n"
       " jne    3b \n"
       "4: \n"
       //Shift to Q1.15 format (i.e. the top 16 bits are returned)
          " rla   %A[z] \n"
       " rlc   %B[z] \n"
       " mov    %B[z],%[x1] \n"
       : [z] "+r"(z), [x1] "+r"(x1)
       : [x] "r"(x), [y] "r"(y));


Reply via email to