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.

[参考译文] TM4C1294KCPDT:读取代码中的内核寄存器

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1522598/tm4c1294kcpdt-reading-core-registers-in-code

器件型号:TM4C1294KCPDT

工具/软件:

尊敬的专家:

您能否提供几行将内核寄存器读取到变量的示例? 例如 SP 寄存器。

谢谢、

挂起。

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

    您好 Hang、

     请参阅以下示例。 SP 加载 R0指向的地址处的内容。 R0稍后会加载地址  APP_START_ADDRESS + 4处的值。  

    ;;
    ;; Load the stack pointer from the application's vector table.
    ;;
    movw r0, #(APP_START_ADDRESS & 0xffff)
    movt r0, #(APP_START_ADDRESS >> 16)

    ldr sp, [r0]

    ;;
    ;; Load the initial PC from the application's vector table and branch to
    ;; the application's entry point.
    ;;
    ldr r0, [r0, #4]
    bx r0

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

    尊敬的 Charles:

    感谢您的示例。 如何将它们置于 C 环境中?

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

    您可以在 C 代码中嵌入汇编代码、如下例所示。  

    asm ("  LDR sp、[r0]);