Technical discussions about the TI C6000 DSPs (including the c62x, c64x and c67x DSPs).
|
I call a assembly in c there is a loop in assembly,and the loop runs 60 times. After finish the assembly the program will done and the cpu will halt. but it will go to the start of main and execute the assembly again. I try step-by-step to see what heppen. I discover that after finish the assembly th PC will point to the start address of main. what problem ??? i don't chang the PC. the assembly code is here------> .def _sind .global _sintable ;60*1 table .global _sintmp ;2*1 matrix for delay k .float 1.98904 .text _sind: MVK 1,A0 INTSP A0,A0 MVKL _sintable,A2 || MVKH _sintmp,B2 MVKH _sintable,A2 || MVKL _sintmp,B2 MVKL k,B4 MVKH k,B4 LDW *B4,B0 || MVK 60,A1 LOOP: SUB A1,1,A1 || LDW *B2,B5 LDW *+B2[1],A5 NOP 4 STW B5,*+B2[1] || MPYSP B0,B5,B4 NOP 3 SUBSP B4,A5,A5 NOP 3 ADDSP A5,A0,A5 NOP 3 STW A5,*B2 || MVK 0,A0 [A1]STW A5,*A2++ NOP 4 [A1]B LOOP NOP 5 .end |
|
|
|
--- nonverbal <> wrote: > I call a assembly in c > there is a loop in assembly,and the loop runs 60 > times. > After finish the assembly the program will done and > the cpu will halt. > > but it will go to the start of main and execute the > assembly again. > I try step-by-step to see what heppen. > I discover that after finish the assembly th PC will > point to the > start address of main. > > what problem ??? i don't chang the PC. > > the assembly code is here------> > .def _sind > .global _sintable ;60*1 table > .global _sintmp ;2*1 > matrix for delay > k .float 1.98904 > .text > _sind: MVK 1,A0 > INTSP A0,A0 > MVKL _sintable,A2 > || MVKH _sintmp,B2 > MVKH _sintable,A2 > || MVKL _sintmp,B2 > > MVKL k,B4 > MVKH k,B4 > LDW *B4,B0 > || MVK 60,A1 > LOOP: SUB A1,1,A1 > || LDW *B2,B5 > LDW *+B2[1],A5 > NOP 4 > STW B5,*+B2[1] > || MPYSP B0,B5,B4 > NOP 3 > SUBSP B4,A5,A5 > NOP 3 > ADDSP A5,A0,A5 > NOP 3 > STW A5,*B2 > || MVK 0,A0 > [A1]STW A5,*A2++ > NOP 4 > [A1]B LOOP > NOP 5 > .end hi - you probably solved that problem long time ago, but in case you didn't... well - I didn't analyze your code in details, but from a quick look - I don't see any Branch (B) except the one before last NOP 5 - you're not returning from that function... that means - after A1 becomes 0 and that last branch is not taken the CPU will simply execute whatever it finds next in the programm memory... right? you have to return to the point where you were before taking that function call... good luck... Wojciech Rewers __________________________________ |
|
Hi, Revers is right. At the end of the assembely code, the following is needed: b .s2 b3 ;according to the C calling conventions, ;b3 is loaded with the return point. ;If you use b3 in your assembly code, you should push it ;to stack at the beginning of your assembly code nop 5 Wang Tao ShangHai ----- Original Message ----- From: Wojciech Rewers <> Date: Wed, 22 Oct 2003 11:12:10 -0700 (PDT) To: nonverbal <>, Subject: Re: [c6x] Infinty Loop ? Re: Re: --- nonverbal <> wrote: Re: > I call a assembly in c Re: > there is a loop in assembly,and the loop runs 60 Re: > times. Re: > After finish the assembly the program will done and Re: > the cpu will halt. Re: > Re: > but it will go to the start of main and execute the Re: > assembly again. Re: > I try step-by-step to see what heppen. Re: > I discover that after finish the assembly th PC will Re: > point to the Re: > start address of main. Re: > Re: > what problem ??? i don't chang the PC. Re: > Re: > Re: > Re: > the assembly code is here------> Re: > .def _sind Re: > .global _sintable ;60*1 table Re: > .global _sintmp ;2*1 Re: > matrix for delay Re: > k .float 1.98904 Re: > .text Re: > _sind: MVK 1,A0 Re: > INTSP A0,A0 Re: > MVKL _sintable,A2 Re: > || MVKH _sintmp,B2 Re: > MVKH _sintable,A2 Re: > || MVKL _sintmp,B2 Re: > Re: > MVKL k,B4 Re: > MVKH k,B4 Re: > LDW *B4,B0 Re: > || MVK 60,A1 Re: > LOOP: SUB A1,1,A1 Re: > || LDW *B2,B5 Re: > LDW *+B2[1],A5 Re: > NOP 4 Re: > STW B5,*+B2[1] Re: > || MPYSP B0,B5,B4 Re: > NOP 3 Re: > SUBSP B4,A5,A5 Re: > NOP 3 Re: > ADDSP A5,A0,A5 Re: > NOP 3 Re: > STW A5,*B2 Re: > || MVK 0,A0 Re: > [A1]STW A5,*A2++ Re: > NOP 4 Re: > [A1]B LOOP Re: > NOP 5 Re: > .end Re: Re: hi - you probably solved that problem long time ago, Re: but in case you didn't... Re: Re: well - I didn't analyze your code in details, but from Re: a quick look - I don't see any Branch (B) except the Re: one before last NOP 5 - you're not returning from that Re: function... that means - after A1 becomes 0 and that Re: last branch is not taken the CPU will simply execute Re: whatever it finds next in the programm memory... Re: right? you have to return to the point where you were Re: before taking that function call... Re: Re: good luck... Re: Re: Wojciech Rewers Re: Re: __________________________________ Re: Re: Re: _____________________________________ Re: Re: Re: Re: Re: Re: -- __________________________________________________________ Sign-up for your own personalized E-mail at Mail.com http://www.mail.com/?sr=signup CareerBuilder.com has over 400,000 jobs. Be smarter about your job search http://corp.mail.com/careers |
|
|
|
mm....thanks but I have a problem how to push data into stack ?? but there is no pop or push instruction... > Hi, > > Revers is right. At the end of the assembely code, the following is needed: > b .s2 b3 ;according to the C calling conventions, > ;b3 is loaded with the return point. > ;If you use b3 in your assembly code, you should push it > ;to stack at the beginning of your assembly code > nop 5 |
|
|
|
--- nonverbal <> wrote: > mm....thanks > > but I have a problem how to push data into stack ?? > > but there is no pop or push instruction... well - I suggest you read chapter 8 from spru187 document... and about push/pop - it's true - there are no dedicated instructions for managing stack - but you can do everything with simple STW, LDW instructions... well - as I said - watch out - there's a learning curve in front of you ;-) good luck... Wojciech Rewers __________________________________ |