【问题标题】:Xtensa instruction: L32R - which addres is loaded?Xtensa 指令:L32R - 加载哪个地址?
【发布时间】:2015-03-14 01:46:22
【问题描述】:

我正在尝试阅读一些 xtensa 汇编代码,但被 L32R 指令难住了:

例如给定以下行:

0000 2f04 <my_func>:
     2f0c:  ffef21          l32r    a2, 2ec8

这会加载哪个地址?

【问题讨论】:

  • 您链接到的文档的第 382 页有更详细的说明。
  • 迈克尔的评论已被纳入下面的答案中。

标签: assembly memory embedded processor xtensa


【解决方案1】:

Xtensa Instruction Set Architecture Reference Manual 手册在第 382 页上指出,l32r 的地址计算如下:

L32R forms a virtual address by adding the 16-bit one-extended constant value encoded
in the instruction word shifted left by two to the address of the L32R plus three with the
two least significant bits cleared. Therefore, the offset can always specify 32-bit aligned
addresses from -262141 to -4 bytes from the address of the L32R instruction. 32 bits
(four bytes) are read from the physical address.

所以继续上面的例子;常量的操作:

     ffef    16-bit constant
ffff ffef    16-bit constant one-extended
ffff ffbc    shifted left by two

电脑操作:

0000 2f0c    program counter
0000 2f0f    pc +3
0000 0f0c    masked bits 0 and 1

虚拟地址的计算:

  ffff ffbc
+ 0000 2f0c
===========
1 0000 2ec8

因此丢弃 16 位以外的所有内容:2ec8

【讨论】:

  • 为什么你的例子中PC的值是2f0c,而原来的例子是2f04?抱歉,如果这看起来很明显,但我是 MCU 的初学者,试图调试显然由我的 ESP8266 上的 l32r 引起的“致命异常 (0)”。
  • @MichaelBöckling 我相信在原始问题中我手动“简化”了反汇编并在此过程中更改了偏移量。它应该是 2f0c 而不是 2f04。我现在已经解决了原来的问题。
【解决方案2】:

L32R 指令从指定地址加载一个 32 位值。因此“l32r a2, 2ec8”将位于地址 0x2ec8 的 32 位值加载到寄存器 a2 中。您必须在反汇编中查看该位置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多