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.

illegal opcode error from linear assembly

Other Parts Discussed in Thread: OMAP-L138

Hi, I am implementing fir filter in linear assembly, but I am getting illegal opcode most of the time. Sometime i'm getting this problem even before stepping into the linear assembly function. I have no Idea what causes this problem, but I do found that some parameter doesn't pass in to the assembly function properly. As for the compiled assembly code, there are .word in most of the asm code, eg:      .word         0x00004c64. Can I know what causes this problem, and what's the solution. Thank you.

  • Which DSP are you using?
    Which device family is selected in the Build Properties box?
    Which version of CCS are you using?
    Which version of Code Generation Tools are you using?

    Have you implemented your application in C first, before trying to write it in assembly? This is the recommended method because

    1. C is much easier to debug.
    2. C is much easier to write.
    3. The compiler will generate assembly that you can examine as an example and to compare with the output from the linear assembler.
    4. If the optimized C version is fast enough, you do not have to write the assembly version; this is true in 90% of cases.

    I recently tried to optimize a C filter function by writing assembly by hand. The cycle count actually increased slightly from the C compiler's optimized version. This made me unhappy with my programming skill because I thought I was a good assembly writer. I did not try to debug the reason why my assembly was slower than the C compiler's assembly because I had a deadline to meet and the performance would not have improved enough for me to justify spending the extra time.

    My recommendation is for you to do the same. Write it in C, optimize it using the methods you find in the C Compiler User's Guide and described elsewhere in the E2E forum and search for C6000 optimization on the TI Wiki Pages.

    Please understand that debugging my own assembly is very difficult. Debugging your assembly is even more difficult, and there is no way that I can help you from your post above. I hope this general information will guide you to a successful path.

    Regards,
    RandyP

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • Hi, I am using omap-L138 chip and the dsp is c6748, I am using  ccs 4.1.2.00027, and I did choose the right device in the build property box. The code generation tool is v6.1.12.

    I have coded the fir filter in hand coded asm previously, and it worked ok, except it cannot be interrupted during the process. I have actually posted this question in other thread, and I was told to implement it in linear asm instead of hand coded asm in order to able to be interrupted. The reason I don't choose to code it in C is because of it's speed, and I need the filter to be as fast as possible. I really appreciate your help to make my linear asm filter work properly. Thank you.

  • Kee Yong Ting,

    Please describe for me in C or pseudo code how you want your FIR filter to operate, including argument types and argument constraints (fixed value, multiple of X, etc.) and return value.

    For example, in the DSPLIB document there is a description of the 16-bit FIR filter of

    16-bit FIR said:
    void DSP_fir_gen(short *x, short *h, short *r, int nh, int nr)
    {
        int i, j, sum;

        for (j = 0; j < nr; j++) {
            sum = 0;
            for (i = 0; i < nh; i++)
                sum += x[i + j] * h[i];
            r[j] = sum >> 15;
        }
    }

    How would yours differ from this?

    Regards,
    RandyP

  • Hi RandyP, below shows the linear asm code that i have coded. It has some logical error, but I don't 
    really know why it keeps showing illegal opcode when i run through the 
    code. Some thing I noticed while doing trial and error is the ADD operation, 
    when I disabled the add operations, the illegal opcode stop appearing, 
    but the x_addr still doesn't load properly after that. The reason I didn't use the 
    DSPLIB fir in the first place is that i need a 32bit fixed point fir filter instead of 16 bit. 
    Hope you can point out my coding mistake. Thank you.
    
    
    
    
    
    
    
    
              			.global _FIR_FILTER
    _FIR_FILTER .cproc X_addr, H_addr, Y_addr, Nh, Ny
    .reg sum_A1, sum_A2, sum_B1, sum_B2, prod1, prod2, sumA, sumB
    .reg x_value2:x_value1, x_value3, h_value2:h_value1
    .reg nh, nh_reset, ny, h_addr, h_addr_reset, x_addr, x_addr_reset, y_addr



    MV X_addr, x_addr
    MV H_addr, h_addr_reset
    MV Y_addr, y_addr
    MV Ny, ny
    MV Nh, nh_reset
    MPYI Nh, 4, x_addr_reset
    SUB x_addr_reset, 8, x_addr_reset

    oloop: .trip 19920
    ZERO sum_A1
    ZERO sum_A2
    ZERO sum_B1
    ZERO sum_B2

    SUB x_addr, x_addr_reset, x_addr
    MV h_addr_reset, h_addr
    MV nh_reset, nh


    iloop: .trip 80
    LDDW *x_addr++, x_value2:x_value1
    LDDW *h_addr++, h_value2:h_value1
    MPYI x_value1, h_value1, prod1
    MPYI x_value2, h_value2, prod2
    ADD sum_A1, prod1, sum_A1
    ADD sum_A2, prod2, sum_A2

    LDW *x_addr, x_value3
    MPYI x_value2, h_value1, prod1
    MPYI x_value3, h_value2, prod2
    ADD sum_B1, prod1, sum_B1
    ADD sum_B2, prod2, sum_B2

    [nh] SUB nh, 2, nh
    [nh] B iloop

    ADD sum_A1, sum_A2, sum_A1
    ADD sum_B1, sum_B2, sum_B1
    STW sum_A1, *y_addr++
    STW sum_B1, *y_addr++

    [ny] SUB ny, 2, ny
    [ny] B oloop

    .endproc
  • If you are doing a cut-and-paste from Word or any formatted text editor, you need to use the Paste from Word. I do not trust any of that, though, and always either type directly into the online edit box or paste into an ASCII-only editor like Notepad (I use the ancient PFE).

    Looking at linear assembly is not going to help. It was a good idea to switch from manual assembly to linear assembly to try to fix the interruptibility problem. But since you have abnormal operation, we do not know if it is your code or something outside of your code.

    My effort to get you to write it in C did not work.

    You will learn a lot in your process of using the debug capabilities in CCS. You will need to study all of the documentation that your various TI support team members have pointed out to you. Your skill at using breakpoints and interpreting the C6000 pipeline operations will be tested and greatly improved through this experience. You will have the opportunity to show your task-assigner your ability to meet the assignment as it is explained to you. I hope you will have the time to share your results with the forum and help others when they have similar problems.

    Regards,
    RandyP