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.

CCS and asm("nop") problem

Other Parts Discussed in Thread: LM3S3748

Greetings --


I am using Code Composer Studio (Version: 4.1.0.02003) to try to build some code for an LM3S3748.  This will be tested on a development kit (LM3S3748 EVB).

For timing purposes, I need to be able to insert the occasional no-op instruction.  This is required to bit-bang signals out of some GPIO pins.  However, if I have the following statement:


asm("nop");

...more than once in a given source file, I get the following assembler error:

"C:\DOCUME~1\agage\LOCALS~1\Temp\0191211", ERROR!   at line 175: [E0300]
         Symbol nop has already been defined
        .dwpsn    file "../trunk/platform/lm3s3748/testfile.c",line 68,column 1,is_stmt

If I put that statement in a different file in the same project, it does not complain.  If I put it twice in any part of the same file, I get the error.  It looks to me as though the assembler is creating a new global symbol out of that statement, and is blowing up when it sees it again.

Since this is really nothing other than C code, I have also tried to build this to an i386 target using gcc under Linux.  I can compile, assemble, and link the same code there without any errors (or solicited warnings).  Thus I know that there is nothing fundamentally wrong with my code.  Obviously I can't execute it there because it tries to access memory-mapped registers directly, but it builds.

Any suggestions?  I have seen sample code posted here where people have had lots of asm("nop") statements that suggests I'm not off base.  Is there a delay function I should be using?  I need 20ns resolution in some cases (I have a very tight loop) so I cannot afford increment/test/branch where a no-op would do.

Thank you.

  • I believe you just need to put a space at the start of the string in the asm statement, asm(" nop").

    The string is passed through directly to the assembler.  Without the leading space the assembly source looks like a line with a label definition and no opcode or operand fields.

  • That did the trick, thanks!  I have managed to avoid doing any assembly up 'til now, so here's hoping that will be the extent of my troubles.