Lc3 LC-3码段

Lc3 LC-3码段,lc3,Lc3,我很难理解这个问题。我有答案,但我真的想知道为什么他们是这样的原因!我了解每个操作码是如何工作的,只是不了解如何将其应用于这个问题 一位工程师正在调试她编写的程序。她正在查看程序的以下部分,并决定在内存中的位置0xA404处放置一个断点。从PC=0xA400开始,她将所有寄存器初始化为零,并运行程序,直到遇到断点 代码段: 0xA400 THIS1 LEA R0, THIS1 0xA401 THIS2 LD R1, THIS2 0xA402 THIS3 LDI R2,

我很难理解这个问题。我有答案,但我真的想知道为什么他们是这样的原因!我了解每个操作码是如何工作的,只是不了解如何将其应用于这个问题

一位工程师正在调试她编写的程序。她正在查看程序的以下部分,并决定在内存中的位置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
遇到断点时以十六进制显示寄存器文件的内容


再一次,我不是在寻找答案列表,而是一个解释来帮助我理解程序中到底发生了什么。非常感谢

如果工程师将断点放在第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