我正在嘗試將當前的 PC 值放入為 xtensa (lx6) 內核撰寫的匯編例程中。在深入研究指令集檔案后,我真的看不出如何實作這一點。看起來 PC 沒有映射到 16 AR,我看不到它列在我可以通過 RSR 指令甚至 RER 指令訪問的暫存器中。
有什么建議嗎?
uj5u.com熱心網友回復:
以下宏是將標簽的完整 32 位運行時地址加載label到暫存器中的可移植(在 xtensa 內核配置之間)方式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的當前值。何時不使用引數,可以省略。a0atara0at
uj5u.com熱心網友回復:
這是一種方法:
.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
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/498478.html
