0

この特定の問題を理解するのに苦労しています。私は答えを持っていますが、なぜそれらが何であるかについての理由を本当に知りたいです! この問題に適用するだけではなく、各オペコードがどのように機能するかを理解しています.....

あるエンジニアが、自分が書いたプログラムをデバッグ中です。彼女はプログラムの次のセグメントを見て、メモリ内の位置 0xA404 にブレークポイントを配置することにしました。PC = 0xA400 から始めて、すべてのレジスタをゼロに初期化し、ブレークポイントに到達するまでプログラムを実行します。

コード セグメント:

0xA400 THIS1 LEA     R0, THIS1 
0xA401 THIS2 LD      R1, THIS2
0xA402 THIS3 LDI     R2, THIS5
0xA403 THIS4 LDR     R3, R0, #2
0xA404 THIS5 .FILL   xA400

ブレークポイントが検出されたときのレジスタ ファイルの内容を (16 進数で) 表示します。

繰り返しますが、私は答えのリストを求めているのではなく、プログラムで正確に何が起こっているのかを理解するのに役立つ説明を求めています. 本当にありがとう!

4

1 に答える 1

0

エンジニアがブレークポイントを行 0xa404 に設定した場合 (0xa404 が実行される前にプログラムを停止した場合)、コードは次のようになります。

0xA400 THIS1 LEA     R0, THIS1  ; LEA loads the address of THIS1 into R0.
                                ; Since THIS1 is at memory location 0xA400, 
                                ; after this instruction R0 = 0xA400

0xA401 THIS2 LD      R1, THIS2  ; LD loads the contents of the memory at
                                ; THIS2 into R1.  Since THIS2 is this very
                                ; line its contents are this instruction,
                                ; which is 0010001111111111 in binary or
                                ; 0x23ff in hex, so after this line executes
                                ; R1 hold 0x23ff

0xA402 THIS3 LDI     R2, THIS5  ; LDI visits THIS5 and treats its value as a
                                ; new memory location to visit.  It visits 
                                ; that second location and stores its 
                                ; contents into R2. In this case, it would
                                ; look at THIS5 and see its value is 0xA400.
                                ; It would then visit 0xA400 and store its
                                ; contents in R2.  0xA400 contains the first 
                                ; line of your program which translates to
                                ; 1110000111111111 in binary, 0xe1ff in 
                                ; hex, so it stores 0xe1ff into R2.

0xA403 THIS4 LDR     R3, R0, #2 ; LDR starts from the memory location of R0,
                                ; adds 2 to that, then stores whatever it 
                                ; finds in that memory location into R3. In
                                ; this case R0 = 0xA400. It adds 2, bringing
                                ; it up to 0xA402, which is the instruction
                                ; immediately above this one.  In binary, that
                                ; instruction is 1010 0100 0000 0001, which
                                ; translates into 0xa401 so the program stores
                                ; the program stores 0xa401 into R3.

0xA404 THIS5 .FILL   xA400      
于 2015-03-03T09:16:14.257 に答える