我正在尝试将当前的PC值转换为为xtensa (lx6)内核编写的程序集。在深入研究指令集文档之后,我无法真正了解如何实现这一点。它看起来好像PC没有映射到16 AR,而且我看不到它列在寄存器中,我可以通过RSR指令,甚至RER指令访问它。
有什么建议吗?
发布于 2022-06-24 12:19:35
下面的宏是一种可移植的方法(在xtensa核心配置之间),可以将标签label的完整32位运行时地址加载到寄存器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-transform块和下面的标签确保在它们之间没有插入文字池或跳转蹦床。
当宏与ar (而不是a0 )一起使用时,它会在临时寄存器at中保留当前的a0值。当ar是a0时,参数at不被使用,可以省略。
发布于 2022-06-22 07:22:52
这里有一个方法可以做到这一点:
.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.nhttps://stackoverflow.com/questions/72702293
复制相似问题