• 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 » [C28x] Intrinsics - difference between __byte and __mov_byte
Share
TI C/C++ Compiler
  • Forum
Options
  • Subscribe via RSS

[C28x] Intrinsics - difference between __byte and __mov_byte

[C28x] Intrinsics - difference between __byte and __mov_byte

This question is answered
Lori Heustess
Posted by Lori Heustess
on Jun 18 2010 16:10 PM
Guru50925 points

Codegen Gurus,

First question:

  • The prototype for __byte in the compiler guide says: int &__byte(int *array, unsigned int byte_index);
  • The '&' seems to be a typo.  Is that correct?

2nd question:

I've been trying to work out the difference between __byte and __mov_byte

Seems

  • __byte can do either a read from or a write into a byte array. 
  • __mov_byte can only do a read from a byte array

But I'm not clear why one would use __move_byte over just __byte to perform the read.    In the few experiments that I tried these two seem generate the same assembly code and are equiv. operations:

  • val = __byte(Array,index);
  • val = __mov_byte(Array,index);

Is there a difference I've missed?

-Lori

Did a reply answer your question? If yes, please click the "yes" button located at the bottom of that post.
Visit these helpful C2000 Links!
C2000 TI Wiki Pages
TI Forum Sitemap
ControlSUITE
C2000 Getting Started
CLA FAQs
Workshop Material!
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 Jun 20 2010 16:26 PM
    Verified Answer
    Verified by Lori Heustess
    Mastermind40870 points

    Lori Heustess

    First question:

    • The prototype for __byte in the compiler guide says: int &__byte(int *array, unsigned int byte_index);
    • The '&' seems to be a typo.  Is that correct?

    It's not a typo, the __byte intrinsic returns a C++-style reference, even in C mode.

    Lori Heustess

    I've been trying to work out the difference between __byte and __mov_byte

    __byte can be used on the left-hand side to set values.  This is the reason it needs to return a reference.

    #include <stdio.h>

    int array[3] = { 0xaaaa, 0xbbbb, 0xcccc };

    void main()
    {
    int i;

    __byte(array, 0) = 0;

    for (i=0;i<3;i++)
    printf("%x\n", array[i]);

    for (i=0;i<6;i++)
    printf("%x\n", __mov_byte(array, i));
    }
    C2000 intrinsics
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Lori Heustess
    Posted by Lori Heustess
    on Jun 23 2010 09:55 AM
    Guru50925 points

    Archaeologist
    It's not a typo, the __byte intrinsic returns a C++-style reference, even in C mode.

    Thanks, Brett  - I suspected a reference, but my C++ fu is currently weak.

    Archaeologist
    __byte can be used on the left-hand side to set values.  This is the reason it needs to return a reference.

    I'm still not sure I quite understand.  I see the flexibility of __byte.  Why would one use __mov_byte instead?  It seems to be not as useful?

    -Lori

     

    Did a reply answer your question? If yes, please click the "yes" button located at the bottom of that post.
    Visit these helpful C2000 Links!
    C2000 TI Wiki Pages
    TI Forum Sitemap
    ControlSUITE
    C2000 Getting Started
    CLA FAQs
    Workshop Material!
    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 Jun 23 2010 12:35 PM
    Verified Answer
    Verified by Lori Heustess
    Mastermind40870 points

    __mov_byte is much older, and was implemented before the compiler could support an intrinsic that returns a reference.  To maintain backward compatibility, __mov_byte was left as-is, and a new intrinsic (__byte) was added which returns the reference.  You are right, there's nothing you can do with __mov_byte that you can't do with __byte.

    C2000 intrinsics
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Lori Heustess
    Posted by Lori Heustess
    on Jun 23 2010 13:03 PM
    Guru50925 points

    Great, thanks Brett -

    I've written this up into a wiki article for folks future reference.

    http://processors.wiki.ti.com/index.php/Byte_Accesses_with_the_C28x_CPU

    -Lori

     

     

    Did a reply answer your question? If yes, please click the "yes" button located at the bottom of that post.
    Visit these helpful C2000 Links!
    C2000 TI Wiki Pages
    TI Forum Sitemap
    ControlSUITE
    C2000 Getting Started
    CLA FAQs
    Workshop Material!
    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