• 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 » Digital Signal Processors (DSP) » C6000 Multicore DSP » Keystone Multicore Forum (C66, 66A, AM5) » Is there a way to access the C66x registers from C-level or do I have to write an asm function?
Share
C6000 Multicore DSP
  • Forums
  • Announcements
Options
  • Subscribe via RSS
Resources
  • KeyStone Multicore DSP + ARM Product Folder
  • Keystone II MCSDK Download
  • Keystone II MCSDK User's Guide

  • KeyStone Multicore DSP Product Folder
  • Keystone I BIOS-MCSDK Download
  • Keystone I BIOS-MCSDK User's Guide

  • Keystone I & II Training

  • C6000 Multicore DSP Product Folder
  • C6000 Multicore Devices

  • DESKTOP-LINUX-SDK 01_00_00_07 Download
  • MCSDK-VIDEO 02_01_00_08 Download

  • C6472 and C6474 Online Training
  • Check out
    Multicore Mix blog
    • $core_v2_blog.Current.Name

      Wireless base stations – why monitor the backup battery?

      Posted 4 days ago
      by Raj Radjassamy
      2G, 3G and 4G LTE base stations use lead-acid batteries as the...
    • $core_v2_blog.Current.Name

      Innovation through smart integration – achieving lower power, high performing small cells

      Posted 4 days ago
      by Debbie Greenstreet
      Wireless small cell market activity is accelerating lately and...
    • $core_v2_blog.Current.Name

      Four for Friday: What’s up at the Small Cells World Summit?

      Posted 18 days ago
      by Debbie Greenstreet
      If you are a follower of the wireless technology, you have probably...

    Forums

    Is there a way to access the C66x registers from C-level or do I have to write an asm function?

    This question is answered
    Weichun Yuan
    Posted by Weichun Yuan
    on May 01 2012 17:55 PM
    Intellectual930 points

    I would like to save the A and B registers into a structure from C level, is there an easy way of doing that? Is there an easy way of doing that from C-level by using intrinsics or other tricks? Anything like the gnu compiler supported asm-format which can process c-variables? Do I have to write a c-callable asm function ?

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • one and zero
      Posted by one and zero
      on May 02 2012 03:43 AM
      Verified Answer
      Verified by Chad Courtney
      Expert6880 points

      Hi,

      there's no way to do that from C. You need to write a C-callable (linear) assembly function.

      Kind regards,

      one and zero

       

      Please click the Verify Answer button on this post if it answers your question.

      You can also follow me on Twitter: http://twitter.com/oneandzeroTI

      Do you want to read interesting multicore articles? Check out our Multicore Mix

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Weichun Yuan
      Posted by Weichun Yuan
      on May 02 2012 11:22 AM
      Intellectual930 points

      On C55x, the ST and some other registers are all memory mapped so that I can access it directly. I could also use the asm in C to move data from registers to memory location directly. Is there a similar way to do that on C66x, as I am not so familiar with the C66x linear assembly?

      To do a automatic calling convention validation (I want to validate algorithm we buy including asm), what else do I have to check on C66x? From the compiler manual, I only saw those related to A0~A15, B0~B15, LC, IRP, NRP, RILC. I do not see any status registers as I used to have to maintain in C54x and C55x. Do I miss anything there? Do you know any existing code somewhere within TI or on the web for such thing?

      thanks

      Weichun

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Allen Lee
      Posted by Allen Lee
      on May 02 2012 22:03 PM
      Genius3520 points

      Hi,

      In C66x, you can also use "asm(" ");" statement to operate on registers in C code. Such as:

      asm(" STW A0,*B15--[1]");   // There must exist a space between the first double quotes and STW.

      asm(" STW A1,*B15--[1]");

      ……

      In this way, you can save all the registers to stack. And then copy out the entire data block to your structure in C.

      Why do you want to make the calling convention validation? It's clearly described by compiler user guide. The status register in C66x is defined in C66x CPU and Instruction Set.

      Allen

      Please press the "Verify Answer" button if you think the post is helpful to your question.Thanks.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • one and zero
      Posted by one and zero
      on May 03 2012 02:25 AM
      Expert6880 points

      Allen,

      please be very careful with asm statements in your C-Code. The compiler rearranges code segments, uses registers freely, and can completely remove variables or
      expressions. Although the compiler never optimizes out an asm statement (except when it is unreachable), the surrounding environment where the assembly code is inserted can differ significantly from the original C/C++ source code.
      It is usually safe to use asm statements to manipulate hardware controls such as interrupt masks, but asm statements that attempt to interface with the C/C++ environment or access C/C++ variables can have unexpected results. After compilation, check the assembly output to make sure your asm statements are correct and maintain the integrity of the program.

      I would really recommend to write an assembly routine that is C-callable rather than using asm statements ...

      Kind regards,

      one and zero

       

      Please click the Verify Answer button on this post if it answers your question.

      You can also follow me on Twitter: http://twitter.com/oneandzeroTI

      Do you want to read interesting multicore articles? Check out our Multicore Mix

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Allen Lee
      Posted by Allen Lee
      on May 03 2012 03:19 AM
      Genius3520 points

      Hi 1&0,

      Thanks for the advice, an assembly routine is definitely a better way. I'm just worrying about the calling of a routine will take effect on the runtime environment such as position of stack pointer or  registers' value. So I'm just trying on asm statement. 

      Anyway, learned a lot from your reply about the background info of asm, thanks.

      Allen

      Please press the "Verify Answer" button if you think the post is helpful to your question.Thanks.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • one and zero
      Posted by one and zero
      on May 03 2012 03:54 AM
      Expert6880 points

      Hi Allen,

      how to interface between assembly and C is described in the Compiler User's Guide (SPRU 187).

      Chapter 7.5 Interfacing C and C++ With Assembly Language

      Please find an example from a previous post:

      http://e2e.ti.com/support/dsp/c6000_multi-core_dsps/f/639/p/159166/578164.aspx#578164

      Kind regards,

      one and zero

       

      Please click the Verify Answer button on this post if it answers your question.

      You can also follow me on Twitter: http://twitter.com/oneandzeroTI

      Do you want to read interesting multicore articles? Check out our Multicore Mix

       

      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