任何人都可以向我解释这个简短的程序是干什么的?了解ARM汇编代码
ORIGIN 0x1000
one DEFW 13
two DEFW 29
three DEFW 0
ORIGIN 0x1010
ENTRY
ADR R0, one
LDR R1, [R0]
LDR R2, [R0, #4]
ADD R1, R2, R1
STR R1, [R0, #8]
SWI 2
如果我想正确的,它增加了“一”到“二”,并将结果在“三”。我对么?
任何人都可以向我解释这个简短的程序是干什么的?了解ARM汇编代码
ORIGIN 0x1000
one DEFW 13
two DEFW 29
three DEFW 0
ORIGIN 0x1010
ENTRY
ADR R0, one
LDR R1, [R0]
LDR R2, [R0, #4]
ADD R1, R2, R1
STR R1, [R0, #8]
SWI 2
如果我想正确的,它增加了“一”到“二”,并将结果在“三”。我对么?
是的。
ORIGIN 0x1000 # Start at address 0x1000
one DEFW 13 # Allocate 4-bytes of space for a variable called one and set it to 13
two DEFW 29 # Allocate 4-bytes of space for a variable called two and set it to 29
three DEFW 0 # Allocate 4-bytes of space for a variable called three and set it to 0
ORIGIN 0x1010 # Skip ahead to address 0x1010 (this really leaves a 4-byte gap)
ENTRY # Mark next instruction as the begining of program
ADR R0, one # Load address of one into R0
LDR R1, [R0] # Load contents of one (pointed to but R0) into R1
LDR R2, [R0, #4] # Load contents of two (pointed to but R0 + 4) into R2
ADD R1, R2, R1 # R1 = R2 + R1
STR R1, [R0, #8] # Store R1 into three (pointed to but R0 + 8)
SWI 2 # Execute a software interrupt
或
three = one + two
不知道的 'SWI 2' 这可能是特定于平台的东西。也许只是程序调用的通用结束。
+1:http://www.ee.ic.ac.uk/pcheung/teaching/ee2_computing/swi.pdf似乎暗示“SWI 2”会打印到某种调试流(至少在该系统上) 。 – Leo
在某些ARM系统上,SWI代表“软件中断”。 –
SWI是软件中断指令。正如@Pete Fordham所说,SWI 2取决于平台。 –
+1为真棒图标! –
这是功课吗?你为什么混淆它?如果你这样做对别人没用。 – tangrs