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.

How to understand the branch instruction exection?



Hi,

I am reading the assembly list file of the compiler before write my asm code. Below the dot line is the asm file from optimizing tutorial lesson3_c.c, there is a branch instruction at address: 00006784 

00006784:   20000011 ||  [ B0]  B.S1          C$L1 (PC+0 = 0x00006760)

What does "C$L1 (PC+0 = 0x00006760)" mean? It means jump to C$L1 when [B0] is not 0? But, in fact it never jumps to C$L1 (PC+0 = 0x00006760) when I step through 00006784. It goes to:

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

C$DW$L$_lesson2_c$3$E, C$L3:

000067e0:   0291307B            ADD.L2X       B9,A4,B5

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

at the loop end.

Could you explain it to me? Thanks.

I am running CCS5.2 on Windows 7 OS.

....................................

       

26            w1 = zptr[0];

          lesson2_c:

00006740:   01980244            LDH.D1T1      *+A6[0],A3

27            w2 = zptr[1];

00006744:   03182247            LDH.D1T2      *+A6[1],B6

00006748:   021B805B ||         SUB.L2        B6,4,B4

0000674c:   03938059 ||         SUB.L1        A4,4,A7

00006750:   039381A2 ||         SUB.S2        B4,4,B7

31                w_vec1 =  xptr[i] * w1;

00006754:   010403E2            MVC.S2        CSR,B2

00006758:   028BCF5A            AND.L2        -2,B2,B5

0000675c:   009403A2            MVC.S2        B5,CSR

          C$L1:

00006760:   00000410            B.S1          C$L2 (PC+32 = 0x00006780)

00006764:   02A03DA3            SHR.S2X       A8,0x1,B5

00006768:   009C52C6 ||         LDH.D2T2      *++B7[2],B1

0000676c:   0210405B            ADD.L2        2,B4,B4

00006770:   01901059 ||         MV.L1X        B4,A3

00006774:   008001A9 ||         MVK.S1        0x0003,A1

00006778:   0017A1A3 ||         SUB.S2        B5,3,B0

0000677c:   040C0940 ||         MV.D1         A3,A8

          C$DW$L$_lesson2_c$3$B, C$L2:

00006780:   0291307B            ADD.L2X       B9,A4,B5

00006784:   20000011 ||  [ B0]  B.S1          C$L1 (PC+0 = 0x00006760)

00006788:   0498AC83 ||         MPY.M2        B5,B6,B9

0000678c:   029C5245 ||         LDH.D1T1      *++A7[2],A5

00006790:   029C22C7 ||         LDH.D2T2      *+B7[1],B5

00006794:   00000001 ||         NOP          

00006798:   00000001 ||         NOP          

0000679c:   00000000 ||         NOP          

000067a0:   0415EDA3            SHR.S2        B5,0xf,B8

000067a4:   928C5255 ||  [!A1]  STH.D1T1      A5,*++A3[2]

000067a8:   02208C81 ||         MPY.M1        A4,A8,A4

000067ac:   0220D079 ||         ADD.L1X       A6,B8,A4

000067b0:   04182C83 ||         MPY.M2        B1,B6,B8

000067b4:   009C52C7 ||         LDH.D2T2      *++B7[2],B1

000067b8:   00000001 ||         NOP          

000067bc:   00000000 ||         NOP          

000067c0:   8087E059     [ A1]  SUB.L1        A1,1,A1

000067c4:   941052D7 ||  [!A1]  STH.D2T2      B8,*++B4[2]

000067c8:   0291EDA1 ||         SHR.S1        A4,0xf,A5

000067cc:   2003E05B ||  [ B0]  SUB.L2        B0,1,B0

000067d0:   0320AC81 ||         MPY.M1        A5,A8,A6

000067d4:   021C2245 ||         LDH.D1T1      *+A7[1],A4

000067d8:   00000001 ||         NOP          

000067dc:   00000000 ||         NOP          

          C$DW$L$_lesson2_c$3$E, C$L3:

000067e0:   0291307B            ADD.L2X       B9,A4,B5

000067e4:   0398AC83 ||         MPY.M2        B5,B6,B7

000067e8:   021C5245 ||         LDH.D1T1      *++A7[2],A4

000067ec:   041C22C7 ||         LDH.D2T2      *+B7[1],B8

000067f0:   00000001 ||         NOP          

000067f4:   00000001 ||         NOP          

000067f8:   00000001 ||         NOP          

000067fc:   00000000 ||         NOP          

 

  • After I verify with machine code, I think the assembler has an error. It should not be:

     

    00006784:   20000011 ||  [ B0]  B.S1          C$L1 (PC+0 = 0x00006760)

     

    The right is:

    00006784:   20000011 ||  [ B0]  B.S1          C$L1 (PC+0 = 0x00006780)

     

    The offset address calculation is wrong in the comiler even the (step) execution is still right. I.e. it is software bug.

  • Sorry, I forgot to correct the label (C$L2, not C$L1) in last post.

    The right is:

    00006784:   20000011 ||  [ B0]  B.S1          C$L2 (PC+0 = 0x00006780)

    The offset address calculation is wrong in the comiler even the (step) execution is still right. I.e. it is software bug.

  • This does appear to be a bug, but it is a bug in the disassembler, not the assembler.

    I've submitted SDSCM00044322 to track this issue.

    This problem does not occur with the command-line dis6x