首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将PC移动到另一个具有xtensa (lx6)核的寄存器中

将PC移动到另一个具有xtensa (lx6)核的寄存器中
EN

Stack Overflow用户
提问于 2022-06-21 14:08:08
回答 2查看 111关注 0票数 0

我正在尝试将当前的PC值转换为为xtensa (lx6)内核编写的程序集。在深入研究指令集文档之后,我无法真正了解如何实现这一点。它看起来好像PC没有映射到16 AR,而且我看不到它列在寄存器中,我可以通过RSR指令,甚至RER指令访问它。

有什么建议吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-06-24 12:19:35

下面的宏是一种可移植的方法(在xtensa核心配置之间),可以将标签label的完整32位运行时地址加载到寄存器ar中。

代码语言:javascript
复制
.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-transform块和下面的标签确保在它们之间没有插入文字池或跳转蹦床。

当宏与ar (而不是a0 )一起使用时,它会在临时寄存器at中保留当前的a0值。当ara0时,参数at不被使用,可以省略。

票数 2
EN

Stack Overflow用户

发布于 2022-06-22 07:22:52

这里有一个方法可以做到这一点:

代码语言:javascript
复制
    .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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72702293

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档