Hello, I have been using CCS 3.1 for EVM DM642. I have the following doubts about TI assembly code: 1. What is the difference between linear code and asssembly code? which one should be stored as .sa and which one should be stored as .asm? There is an assembly optimizer in CCS. Which of these does the optimizer optimize? 2. I have written a small function(procedure) in assembly and call it form main which is written in c. the first line is _foo: .cproc ap, bp, rp but the compiler gives and error: "foo.asm", ERROR! at line 5: [E0002] Illegal mnemonic specified _foo: .cproc ap, bp, rp Same errors come when .endproc and .return are used. Could someone help in these issues? anyhow the assembly procedure is executing sucessfully whithout .cproc because the parameters are stored by default in A4,B4 and A6 regards APS
TI Assembly code problems
Started by ●March 21, 2007
Reply by ●March 21, 20072007-03-21
salaria wrote:> Hello, > > I have been using CCS 3.1 for EVM DM642. I have the following doubts about > TI assembly code: > > 1. What is the difference between linear code and asssembly code? which > one should be stored as .sa and which one should be stored as .asm? There > is an assembly optimizer in CCS. Which of these does the optimizer > optimize?The c6000 architecture is a VLIW architecture. It can execute 8 instructions in parallel every single cycle. If you write an asm file then you are writing the code exactly as you want it to be executed on the device. That is, you could be writing up to 8 instructions in parallel and you also need to have full understanding of the pipeline. For example, you need to wait 5 cycles after a load before you can use the data. In an sa file (serial assembly) you write assembly as if it was for a non VLIW architecture. You also don't have to worry about the pipeline. For example you can do a load in one instruction and then use that variable in the next instruction and everything will work correctly. That is, the assembly optimizer (which operates on sa files) will turn your linear/serial code into proper parallel asm code where it waits the appropriate number of cycles.> 2. I have written a small function(procedure) in assembly and call it form > main which is written in c. the first line is > > _foo: .cproc ap, bp, rp > > but the compiler gives and error: > > "foo.asm", ERROR! at line 5: [E0002] Illegal mnemonic specified > _foo: .cproc ap, bp, rp > > Same errors come when .endproc and .return are used. > > Could someone help in these issues? anyhow the assembly procedure is > executing sucessfully whithout .cproc because the parameters are stored by > default in A4,B4 and A6 > > regards > APSThe commands you're using apply only to linear/serial assembly. You need to change your file extension to sa in order to use those directives. There's some additional documentation about this in the c6000 DSP Programmer's Guide. Brad
Reply by ●March 21, 20072007-03-21
Hello APS,> 1. What is the difference between linear code and asssembly code?Linear code is a kind of preliminary stage to assembly code. Linear code is assembled to assembly code.> one should be stored as .sa and which one should be stored as .asm?.sa = serial assembly file .asm = assembly file> is an assembly optimizer in CCS. Which of these does the optimizer > optimize?Only the linear, assembly is ready to run. Nothing is changed.> 2. I have written a small function(procedure) in assembly and call it form > main which is written in c. the first line isYou should take a look possibly to: "TMS320C6000 Optimizing Compiler User's Guide" 8.5.1 Using Assembly Language Modules With C/C++ Code "TMS320C64x/C64x+ DSP CPU and Instruction Set Reference Guide" Is important for assembly code.> Could someone help in these issues? anyhow the assembly procedure is > executing sucessfully whithout .cproc because the parameters are stored by > default in A4,B4 and A6Thats right. Without looking in you code you can take a look into a library of the DSP: dsp64x_sa.src There are examples for .sa - files. Put this code in a *.asm-file add it to your project: ---------------------------------------------------- .global _blabla _copyzero8: ZERO .D1 A0 ; Nothing of interest RET .S2 B3 NOP 5 ---------------------------------------------------- in *.c add: ---------------------------------------------------- void blabla(Ptr whatyouwant, int otherstuff); ---------------------------------------------------- Regards, Wolfgang
Reply by ●March 23, 20072007-03-23
My serial assembly code is running well, thank you. But i observed that c-code at file optimization level is still faster than serial assembly code. APS>Hello APS, > >> 1. What is the difference between linear code and asssembly code? > >Linear code is a kind of preliminary stage to assembly code. >Linear code is assembled to assembly code. > >> one should be stored as .sa and which one should be stored as .asm? > >.sa = serial assembly file >.asm = assembly file > >> is an assembly optimizer in CCS. Which of these does the optimizer >> optimize? > >Only the linear, assembly is ready to run. Nothing is changed. > >> 2. I have written a small function(procedure) in assembly and call itform>> main which is written in c. the first line is > >You should take a look possibly to: > >"TMS320C6000 Optimizing Compiler User's Guide" >8.5.1 Using Assembly Language Modules With C/C++ Code > >"TMS320C64x/C64x+ DSP CPU and Instruction Set Reference Guide" >Is important for assembly code. > >> Could someone help in these issues? anyhow the assembly procedure is >> executing sucessfully whithout .cproc because the parameters are storedby>> default in A4,B4 and A6 > >Thats right. > >Without looking in you code you can take a look into a library of theDSP:> dsp64x_sa.src >There are examples for .sa - files. > >Put this code in a *.asm-file add it to your project: >---------------------------------------------------- > .global _blabla >_copyzero8: > ZERO .D1 A0 ; Nothing of interest > RET .S2 B3 > NOP 5 >---------------------------------------------------- >in *.c add: >---------------------------------------------------- >void blabla(Ptr whatyouwant, int otherstuff); >---------------------------------------------------- > > Regards, Wolfgang > > >
Reply by ●March 23, 20072007-03-23
Hello APS, You can write let's say suboptimal serial assembly code. And also for serial assembly there are optimization possibilities also. To write serial assembly code you must have deep knowledge about DSP's way of accessing registers and memory. It only helps you with e.g. preamble of loops and keeping all delay times which is a real burden if you have to change assembly code. Regards, Wolfgang "salaria" <apsalaria@gmail.com> schrieb im Newsbeitrag news:NNKdndysmLD9SJ7bnZ2dnUVZ_qWvnZ2d@giganews.com...> My serial assembly code is running well, thank you. But i observed that > c-code at file optimization level is still faster than serial assembly > code. > > APS