2

このショートプログラムが何をするのか誰かに説明してもらえますか?

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

私が正しく考えている場合は、「1」を「2」に追加し、結果を「3」に配置します。私は正しいですか?

4

1 に答える 1

7

はい。

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」については不明です。おそらく、お使いのプラットフォームに固有のものです。たぶん、プログラム呼び出しの一般的な終了です。

于 2012-11-21T19:40:01.687 に答える