• 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) » C5000 Ultra Low Power DSP » C5000 Ultra Low Power DSP Forum » 54x Stack Addressing - Assembler Fails to Recognize?
Share
C5000 Ultra Low Power DSP
  • Forum
  • Announcements
Options
  • Subscribe via RSS
Top 6 Wiki Links
  • C5000 Main Wiki
  • C5000 Software
  • C5515 Boot-Image Programmer
  • CSL (including CSL 3.00)
  • C5000 Connected Audio Framework
  • Porting C5000 Teaching ROM to C5535 eZdsp
  • 54x Stack Addressing - Assembler Fails to Recognize?

    54x Stack Addressing - Assembler Fails to Recognize?

    This question is answered
    Micah Dombrowski
    Posted by Micah Dombrowski
    on May 28 2012 02:16 AM
    Prodigy100 points

    Hi,

    I'm trying to use 54x DSP Library functions (cbrev, cfft1024, log_10), in pure assembly, on a 542 chip.  Even though I am passing -mc to the assembler, it does not seem to be recognizing the SP as a valid MMR, or...something.  The code (w/ CPL=1) is, e.g.

        .asg    (0), DATA
        stl        a, *sp(DATA)

    but after compiling to COFF and loading through an emulator is disassembled as

        STL A, IMR

    overwriting my IMR (at absolute address 0).  Wat.  Every other attempted form of this either gives an error, overwrites the IMR, or writes directly to SP itself, and not the stack.  Other instances of this (with .asg (N), NAME and references to *sp(NAME) also write to absolute address N).

    There is heavy use of this form of SP-relative addressing in the DSPLIB code, and I don't think it's working properly in any of the functions.  What's going on?  Is this the correct way to do SP-referenced addressing?  If not, can someone give me a working example?

    Compiling with CCSv5 c5400 tools.

    stack assembler 54x
    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 May 28 2012 09:27 AM
      Verified Answer
      Verified by Micah Dombrowski
      Mastermind40550 points

      You are using the "direct addressing" addressing mode.  This mode is either DP-relative or SP-relative depending on the value of the CPL bit.  It looks like the assembler is encoding this instruction correctly.  The behavior you are describing is consistent with the CPL bit being set to 0.  Are you absolutely sure the CPL bit is 1 when that instruction is executed?

      The -mc option does not affect hand-coded assembly code.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Micah Dombrowski
      Posted by Micah Dombrowski
      on May 28 2012 15:17 PM
      Prodigy100 points

      Yeah, okay, I think I found the bug.  cfft1024 uses SP-relative addressing -before- setting ST1 up (which includes CPL=1), so if you don't already have CPL = 1, badness occurs.

      The other annoying thing is that I actually noticed that bug early, and changed it, but the disassembler apparently doesn't pay attention to CPL, so I wandered off on that -mc tangent because the disassembled code still looked wrong.  It's actually fine when I let it run, but the no matter what the value of CPL (or use of -mc), the disassembler reads op code 8000 as "STL A, IMR", never as "STL A, top-of-stack-address".

      Blerg.

      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 May 28 2012 20:26 PM
      Mastermind40550 points

      As to cfft1024, if it is intended to be a C-callable function, it is entitled to believe that CPL=1, as that is part of the C calling convention.  If it is not intended to be a C-callable function, I can't say much about it.  We'd need an expert on the library to comment on it.

      As to the disassembler, yes, that is annoying.  When disassembling code in the debugger, the debugger should query the status bit and disassemble accordingly.  Note that if CPL changes during execution, this will not be reliable unless the PC is actually on that instruction.  The C55x disassembler behaves like this.  However, I don't know if it is feasible to change the C54x disassembler at this time.

      As to -mc, it's not a valid C54x assembler option.  How exactly are you using it?

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Micah Dombrowski
      Posted by Micah Dombrowski
      on May 28 2012 22:39 PM
      Prodigy100 points

      It is intended to be called from C, but the doc (spru518d) says asm calls should be possible.

      The asm tools guide (spru102f) claims that -mc is valid?  I'm not using it anymore, though, I was just trying everything until I realized the disassembler was lying, and moving the ST1 setup two lines earlier fixed the problem.  On the other hand, upon checking, I found that log_10 never changes CPL at all, so I guess 'possible' doesn't mean 'transparent'.

      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 May 29 2012 08:37 AM
      Mastermind40550 points

      You can do anything from assembly code that you could do from C code, such as call a C-callable function.  When calling a C-callable function, this means you must adhere to the C calling convention, which includes setting the status bits before calling it.

      That's an error on SPRU102F; the -mc option is actually intended for C55x only.

      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