LC3 LEA instruction and the value stored

試著忘記壹切 提交于 2019-12-24 10:46:56

问题


I am confused by this question: What is the value stored in register 0 after instruction “LEA R0,A" is executed? How come the answer is x370C ? I reckon it is supposed to load the address of A into R0? If so how do we know the address? Can someone please help? Many thanks!

.ORIG X3700
 LEA R0, A
 LDI R2, C LDR R3, R0, 2 
 AND R1, R1, #0 
 IN
 ST R0, D 
 JSR  F 
 HALT
F LD  R1, B
 ADD R1, R1, #1
 BRp F 
 RET

 A .FILL X1234
 B .FILL X370B
 C .FILL X370C
 D .BLKW 2
 E .STRINGZ "ABCD"
 G .FILL X1234
 .END

回答1:


The origin of the code is x3700, and you have 12 instructions, so the address of A will be x3700 + x0C = x370C. As you guessed, LEA R0,A loads the address of A into R0, so R0 will contain x370C after that first instruction has been executed.

        .ORIG X3700
3700     LEA R0, A
3701     LDI R2, C
3702     LDR R3, R0, 2 
         ...
370b     RET

370c     A .FILL X1234
         ...


来源:https://stackoverflow.com/questions/25866566/lc3-lea-instruction-and-the-value-stored

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!