• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Development Tools » TI C/C++ Compiler » TI C/C++ Compiler - Forum » TMS470 Compiler and inline Assembly
Share
TI C/C++ Compiler
  • Forum
Options
  • Subscribe via RSS

Forums

TMS470 Compiler and inline Assembly

This question is answered
PaulT
Posted by PaulT
on Aug 18 2010 14:22 PM
Prodigy100 points

I am using CCS 4.1.3 and targeting a LM3S6432 Cortex M3 processor. I am trying to build FreeRTOS for this processor and the interface layer of the port uses a lot of inline assembly code in their C  modules. I have started to modify these but I can not find a definitive reference of what the compiler supports. It seems to support some features as described in the gcc documentation though little from the ARM SDT compiler documentation. I can not find any TI documentation that describes what the compiler will support so that I may modify the macros. I started some trial and error but that is taking too long. Does anyone know of a Compiler Reference  for the Arm Compiler in CCS that will describe exactly what the compiler will support in the __asm block?

Thank You!

Paul

Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Archaeologist
    Posted by Archaeologist
    on Aug 18 2010 14:28 PM
    Mastermind40800 points

    The string in an __asm statement appears verbatim in the output assembly file.  There is no processing done on the string by the compiler.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • PaulT
    Posted by PaulT
    on Aug 18 2010 14:44 PM
    Prodigy100 points

    Thanks for the reply. I thought that was the case but

        __asm volatile                                        \
        (                                                    \
            "    mov r0, #(5 << 5)                        \n"    \
            "    msr basepri, r0                            \n" \
            :::"r0"                                            \
        )
    works and :::"r0", which is described in the GCC version of the compiler, does not show up in the output so it is being filtered somewhere. If I add

    int mask;

    ...

    __asm volatile                                        \
        (                                                    \
            "    mov r0,  #(5 << 5)                        \n"    \
            "    msr basepri, r0                            \n" \
            ::"i"(mask):"r0"                                            \
        )

    the ::"i"(mask):"r0"  is again filtered out of the assembler file with no warnings or errors, if i change #(5 << 5) to %0  the %0 parameter reference is not modified and the assembler fails with an error. Adding a parameter name as in

    __asm volatile                                        \
        (                                                    \
            "    mov r0, #(5 << 5)                      \n"    \
            "    msr basepri, r0                            \n" \
            ::[assmblerMask]"i"(mask):"r0" 

       )

    does cause the compiler to issue an error saying that it is expecting a "(". That is why I think that it supports some limited amount assembler preprocessing but not all.

    Regards,

    Paul

     

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Archaeologist
    Posted by Archaeologist
    on Aug 18 2010 15:04 PM
    Mastermind40800 points

    I can't get the TI ARM compiler to accept any of these.  Are you sure you're passing this code to the TI compiler?  What are your command line options?  Could you post a cutdown (but compilable) C file?

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • PaulT
    Posted by PaulT
    on Aug 18 2010 15:32 PM
    Prodigy100 points

    Header File

    #ifndef PORTMACRO_H
    #define PORTMACRO_H

    #ifdef __cplusplus
    extern "C" {
    #endif

    #define portSET0()                        \
        __asm volatile                                        \
        (                                                    \
            "    mov r0, #(5 << 5)                        \n"    \
            "    msr basepri, r0                            \n" \
            :::"r0"                                            \
        )

    #define portSET1()                        \
        __asm volatile                                        \
        (                                                    \
            "    mov r0, #(5 << 5)                        \n"    \
            "    msr basepri, r0                            \n" \
            ::"i"(interruptMask):"r0"                                            \
        )

    #define portSET2()                        \
        __asm volatile                                        \
        (                                                    \
            "    mov r0, %0                                \n"    \
            "    msr basepri, r0                            \n" \
            ::"i"(interruptMask):"r0"                                            \
        )

    #define portSET3()                        \
        __asm volatile                                        \
        (                                                    \
            "    mov r0,  #(5 << 5)                        \n"    \
            "    msr basepri, r0                            \n" \
            ::"i"(interruptMask):"r0"                                            \
        )

    #define portSET4()                        \
        __asm volatile                                        \
        (                                                    \
            "    mov r0,  #[mask]                        \n"    \
            "    msr basepri, r0                            \n" \
            ::[mask]"i"(interruptMask):"r0"                    \
        )

    #ifdef __cplusplus
    }
    #endif

    #endif /* PORTMACRO_H */

    and the C File

     

    #include "portmacro.h"

    void foo()
    {
        int interruptMask = (5 << 5);
        portSET0();
        portSET1();
        portSET2();
        portSET3();
        portSET4();
    }

    The command line is

    E:/Program Files/Texas Instruments/ccsv4/tools/compiler/tms470/bin/cl470" -mv7M3 -g -O2 --gcc --define=ccs --define=PART_LM3S6432 --include_path="E:/Program Files/Texas Instruments/ccsv4/tools/compiler/tms470/include" --include_path="E:/Projects/CCS4/LuminaryMicro/include" --diag_warning=225 -me --gen_func_subsections --abi=eabi --code_state=16 -k --ual --preproc_with_compile --preproc_dependency="source/port.pp" --obj_directory="source"  "../source/port.c"

    The compiler fails on the line portSET4().

    Generated asm output

        .dwpsn    file "../source/port.c",line 6,column 2,is_stmt
        mov r0, #(5 << 5)                       
        msr basepri, r0                           
        .dwpsn    file "../source/port.c",line 7,column 2,is_stmt
        mov r0, #(5 << 5)                       
        msr basepri, r0                           
        .dwpsn    file "../source/port.c",line 8,column 2,is_stmt
        mov r0, %0                               
        msr basepri, r0                           
        .dwpsn    file "../source/port.c",line 9,column 2,is_stmt
        mov r0,  #(5 << 5)                       
        msr basepri, r0                           
        .dwpsn    file "../source/port.c",line 11,column 1,is_stmt
    $C$DW$2    .dwtag  DW_TAG_TI_branch
        .dwattr $C$DW$2, DW_AT_low_pc(0x00)
        .dwattr $C$DW$2, DW_AT_TI_return
            BX        LR

    If portSET4() is commented out then it fails in the assembler. "port.asm", ERROR!   at line 60: [E0200] Bad term in expression
            mov r0, %0                               

    Generated asm output is identical.

     

    Regards,

    Paul

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Archaeologist
    Posted by Archaeologist
    on Aug 18 2010 16:11 PM
    Mastermind40800 points

    I think I'm stumped at this point.  As far as I know, the compiler shouldn't (and in fact for me doesn't) accept any of those.  I get two errors on each of the five invocations, "expected '('" and "expected ')'", just as I expect.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • PaulT
    Posted by PaulT
    on Aug 19 2010 08:16 AM
    Prodigy100 points

    Just getting back to my original question. What is the definitive reference for this compiler?

    -Paul

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Archaeologist
    Posted by Archaeologist
    on Aug 19 2010 12:04 PM
    Mastermind40800 points

    PaulT

    What is the definitive reference for this compiler?

    -Paul

    The TMS470 C/C++ Optimizing Compiler User's Guide

    This page lists the compiler user's guides for the various targets.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • PaulT
    Posted by PaulT
    on Aug 19 2010 16:06 PM
    Prodigy100 points

    Thank You, I just never ran across that page.

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Paul Knueven
    Posted by Paul Knueven
    on Aug 19 2010 19:44 PM
    Verified Answer
    Verified by George Mock
    Expert4280 points

    Paul,

    We do not currently support the GCC "Extended Asm" feature, but our implementation fails to reject it.  Our asm statement is supposed to behave as Archaeologist and the manual say, but when the --gcc option is used, the compiler accepts the GCC extended asm syntax and then ... does nothing with it.  Needless to say, this will be fixed in a future release.   By "fixed" I mean the Extended Asm will be rejected; possibly not what you were hoping for, but better than leading you on by swallowing the syntax.

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use