ARM汇编中str的解释 [英] Explanation of str in ARM assembly

查看:32
本文介绍了ARM汇编中str的解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

奇怪的是,我找不到关于 str 如何在汇编语言中工作的解释.

Strangely, I cannot find an explanation as to how str works in assembly language.

我了解以下...

str r1,[r2]

...将存储寄存器 1 r1 中的任何内容,在寄存器 2 的地址 r2 中.但是,我想解释一下当方括号复杂得多时 str 是如何工作的.例如:

...will store whatever is in register 1, r1, in the address of register 2, r2. However, I would like an explanation as to how str works when the square brackets are much more complicated. For example:

str r1,[r0,r3,lsl#2]

这里发生了什么?我想知道 r1 的值会在哪里结束,它的值是什么.我无法对其进行测试,因此我将猜测一下我的想法.

What is going on here? I want to know where the value of r1 will end up, and what will be its value. I can't test it, so I am going to take a guess as to what I think is going on.

r3 在逻辑上移位 2.然后将其添加到 r0.最后,将 r1 添加到 r0.

r3 is logically shifted by 2. It is then added to r0. Finally, r1 is added to r0.

这是我的猜测,即使对我来说这听起来也不正确.有人可以为我澄清一下吗?

This is my guess, though even to me this does not sound correct. Can someone clarify this for me?

推荐答案

str r1,[r0,r3,lsl#2]

这里发生了什么?

上面的指令基本上是说:r0 + (r3 <<2) = r1,或者如果我们手动扩展"位移:r0 + (r3 * 4) = r1

The instruction above basically says: r0 + (r3 << 2) = r1, or if we manually "expand" the bit-shift: r0 + (r3 * 4) = r1

符号是;<src>[<dst>、<offset>、<shift>].

请注意,偏移量也可以为负(例如 -r3、#lsl2).

Note that offsets can also be negative (e.g. -r3, #lsl2).

我想知道 r1 的值会在哪里结束,以及它的值是什么.

I want to know where the value of r1 will end up, and what will be its value.

您需要知道 r0r3 在执行期间的特定时间点的实际值,然后才能知道这些.这就像问y = f(x) : x * 2y 的值是多少?"对 x 一无所知.

You need to know the actual values of r0 and r3 at a specific point in time during its execution before you can know any of this. This is like asking "What is the value of y in y = f(x) : x * 2?" without knowing anything about x.

r3 在逻辑上移位 2.然后将其添加到 r0.

r3 is logically shifted by 2. It is then added to r0.

是的.

最后将 r1 添加到 r0.

Finally, r1 is added to r0.

r1 中的数据存储在(未添加到)左侧计算的位置.

The datum in r1 is stored in (not added to) the location calculated by the left-hand side.

这篇关于ARM汇编中str的解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆