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.

[参考译文] 编译器:如何从CMSIS gcc仿真__GET_IPSR()

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

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/655272/compiler-how-to-emulate-__get_ipsr-from-cmsis-for-gcc

工具/软件:TI C/C++编译器

您好,

我目前正在使用TI的armcl编译器测试MSP432的内部固件。 很遗憾,我遇到了一个问题:我找不到内置或帮助程序来提取IPSR寄存器(当前中断号)的内容。 我已经尝试为gcc重复使用CMSIS的版本

__attribute___((always内联))__static_inline uINT32_t __GET_IPSR(void)
{
UINT32_t result;

__ASM volatile ("MRS %0,ipsr":"=r"(result));
return (result);
} 

采用以下方式:

uINT32_t __GET_IPSR(void){
UINT32_t result;

__ASM ("MRS %0,ipsr":"=r"(result));
返回结果;
}

但不幸的是,编译器终止时出现“错误#18:预期为“”)”(关于包含__asm语句的行)。

是否有人更熟悉TI的汇编语法,可以帮助我解决问题?

提前感谢!

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

    请尝试这个...

    //禁止关于此函数的警告不返回值
    #pragma diag_suppress 994
    __attribute___(裸体))
    UINT32_t __Get_IPSR(void)
    {__ASM("
    Mrs R0, IPSR\n");}//
    
    恢复关于任何非void函数的警告不返回值
    #pragma diag_default 994 

    谢谢,此致,

    -George