问题描述
我有以下组装code:
阿尔法:64。空间64 @reserves字节
我:INT 0
。文本
.align2
.globalmain
.FUNC主
主要:
LDR R3,= I @ R3是我的地址
MOV R2,#0 @ r2为0
海峡R2,[R3] // @ R2存在R3
L1:
LDR R3,= I @ R2是我的地址
LDR R2,[R3] // @ R2现在是我的地址
CMP R2,#16
BGE退出@if R2> 16,然后退出(但不是)
LDR R3,= I @ R3是我的地址
LDR R2,[R3] // @ R2是我的地址
添加R1,R2,#为0x200 @ r1为R2 +为0x200
LDR R3 =阿尔法@ R3是阿尔法数组第一个元素的地址(我认为)
STR R1,[R3,R2,翔升#2]
...
我知道它的很多,但我只有麻烦的一部分。我评论我知道的地方,或者至少我觉得我知道了。
我有麻烦的是 STR R1,[R3,R2,翔升#2]
。我知道翔升#2
是一个左移,但这是我真正知道了。哪里R1获取存储在R3?会是什么 STR
命令的结果?有人能解释一下吗?
STR R1,[R3,R2,翔升#2]
在的r2值是由(立即值)移位arithematic左2,并加入到r3的内容,以获得在其中R1将被存储在存储器地址
I have the following assembly code:
alpha: .space 64 @reserves 64 bytes
i: int 0
.text
.align2
.globalmain
.func main
main:
ldr r3,=i @r3 is address of i
mov r2,#0 @r2 is 0
str r2,[r3] @r2 is stored in r3
L1:
ldr r3,=i @r2 is address of i
ldr r2,[r3] @r2 is now address of i
cmp r2,#16
bge exit @if r2 > 16, then exit (but it is not)
ldr r3,=i @r3 is address of i
ldr r2,[r3] @r2 is address of i
add r1,r2,#0x200 @r1 is r2 + 0x200
ldr r3,=alpha @r3 is address of first element in array alpha (I think)
str r1,[r3,r2,asl#2]
...
I know its alot, but I only have trouble with one part. I commented the parts I do know, or at least I think I know.
The trouble I'm having is with str r1,[r3,r2,asl#2]
. I know asl#2
is a left shift, but that's all I really know. Where does r1 get stored, in r3? What would be the result of the str
command? Can someone explain it for me?
str r1,[r3,r2,asl#2]
value in r2 is arithematic left shifted by (immediate value) 2 and is added to the contents of r3 , to get the memory address at which r1 will be stored.
这篇关于了解在海峡ARM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!