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.

[参考译文] TMS320F28388D:以 C 代码获取 SP

Guru**** 2606725 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1002451/tms320f28388d-getting-sp-in-c-code

器件型号:TMS320F28388D

您好!

我想在 c 代码中获取栈指针,这样就可以监控栈。我已经通过其他论坛了解到 C28x SP 不是内存映射的,需要 C 可调用的汇编函数来获取 SP。

是否有可用的 c 可调用汇编函数示例、或者是否有人展示了如何执行相同操作。

谢谢、

Stevin Martin

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Martin:

    您必须编写 一个可调用 c 的汇编函数、该函数返回 SP

    汇编函数读取 SP 并返回其值。 然后、您可以从 C 代码调用此汇编函数。  

    例如:

    汇编代码

       全局_varSP
       全局_getsp

    getsp:
           MOV   AL、SP
           MOV    @_varSP、AL        
           LRET

    C 代码

    extern "C"{
    extern int getsp();        /*声明外部 asm 函数*/
    int varSP = 0;             /*定义全局变量以存储 SP */

    void main()
    {   
       getsp();       /*调用函数通常        为*/

    此致

    Siddharth