将PC带入Xtensa(LX6)内核的另一个寄存器

发布于 2025-02-09 06:24:02 字数 127 浏览 3 评论 0原文

我正在尝试将当前的PC值纳入为Xtensa(LX6)内核编写的装配程序。挖掘指令集文档后,我看不到如何实现这一目标。看来PC没有映射到16 AR中,我看不到它可以通过RSR指令甚至RER指令列出我可以访问的寄存器。

有建议吗?

I'm trying to get the current PC value into an assembly routine written for xtensa (lx6) cores. After digging into the instruction set doc, I cannot see really how to achieve this. It looks as if the PC is not mapped into the 16 AR, and I cannot see it listed into the registers I can access through the RSR instruction, or even the RER instruction.

Any advice ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

离不开的别离 2025-02-16 06:24:02

以下宏是一种可移植(Xtensa核心配置之间),用于加载标签的完整32位运行时地址label到寄存器ar

.macro  get_runtime_addr label, ar, at
        .ifgt 0x\ar - 0xa0
        mov     \at, a0
        .endif
        .begin  no-transform
        _call0  1f
\label:
        .end    no-transform
        .align  4
1:
        .ifgt 0x\ar - 0xa0
        mov     \ar, a0
        mov     a0, \at
        .endif
.endm

no--转换围绕呼叫的阻挡,以下标签可确保它们之间没有插入字面的池或跳跃蹦床。

当宏与ar使用a0以外,它将保留当前a0值在临时寄存器 at 中。当ara0时, at 不使用 不使用,可能会省略。

The following macro is a portable (between xtensa core configurations) way to load full 32-bit runtime address of the label label into the register ar:

.macro  get_runtime_addr label, ar, at
        .ifgt 0x\ar - 0xa0
        mov     \at, a0
        .endif
        .begin  no-transform
        _call0  1f
\label:
        .end    no-transform
        .align  4
1:
        .ifgt 0x\ar - 0xa0
        mov     \ar, a0
        mov     a0, \at
        .endif
.endm

The no-transform block around the call and the following label ensures that no literal pool or jump trampoline is inserted between them.

When the macro is used with ar other than a0 it preserves the current a0 value in the temporary register at. When ar is a0 the argument at is not used and may be omitted.

冰火雁神 2025-02-16 06:24:02

这是一种做到这一点的方法:

    .file   "getpc.S"
    .text
.Ltext0:
    .section    .text.get_pc,"ax",@progbits
    .align  4
    .global called_routine
    .type   called_routine, @function

// All this mess to get the PC (roughly) !

// This routine is called just to get the caller return address
// it is stored into the a0 register
called_routine:    
    entry   a1, 32
    mov     a2,a0
    retw.n


// This routine obtains something which contains 30 bits of the PC
// Please refer the xtensa instruction set manual (CALL8) for more information
// on how to rebuild the topmost 2 bits of it
    .align  4
    .global get_pc
    .global get_pc_return_address
    .type   get_pc, @function
get_pc:
    entry   a1, 32

    call8   called_routine
get_pc_return_address:
    mov.n   a2, a10
    retw.n

Here is a way to do this :

    .file   "getpc.S"
    .text
.Ltext0:
    .section    .text.get_pc,"ax",@progbits
    .align  4
    .global called_routine
    .type   called_routine, @function

// All this mess to get the PC (roughly) !

// This routine is called just to get the caller return address
// it is stored into the a0 register
called_routine:    
    entry   a1, 32
    mov     a2,a0
    retw.n


// This routine obtains something which contains 30 bits of the PC
// Please refer the xtensa instruction set manual (CALL8) for more information
// on how to rebuild the topmost 2 bits of it
    .align  4
    .global get_pc
    .global get_pc_return_address
    .type   get_pc, @function
get_pc:
    entry   a1, 32

    call8   called_routine
get_pc_return_address:
    mov.n   a2, a10
    retw.n
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文