如何做一个的LEA指令店地址? [英] How does LEA instruction store address of A?
问题描述
这是基于关闭这个问题 LEA指令
This is based off this question LEA instruction
下面是code段我有一个关于
Here is the code segment I have a question about
.ORIG X3700
LEA R0, A
.....
A .FILL X1234
@保罗R,答案应答,表示code的起源是x3700,你有12个指令,所以A的地址将是x3700 + X0C = x370C。正如你猜到了,LEA R0 ,A加载进R0的地址,这样第一个指令已经执行后R0将包含x370C。
@Paul R, the answer responder, said that "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."
我同意保罗所说的第一部分,他的推理为什么A的地址是x370C。这就说得通了。
I agree with the first part of what Paul said, his reasoning for why the address of A is x370C. That makes sense.
我感到困惑的下一个部分,即LEA R0,A加载的地址复制到R0。这是对LEA指令幻灯片我参考了。 LC3 LEA ,5-23
I am confused about the next part, that "LEA R0, A loads the address of A into R0". This is the slide my reference has on the LEA instruction. Lc3 LEA, 5-23
不同于ADD和和说明,机关指令只有一个模式。(参考指定ADD两种模式,并与
Unlike the ADD and AND instructions, the LEA instruction has only one mode.(reference specifies both modes for ADD and AND.
从这个图中,LEA的第二部分,A应该PCoffset 9.但是A的值是4660(十进制)从,A X1234 .fill伪,这超出了PCoffset 9范围内,这是-256到255)。
任何人能解释这是怎么回事?我使用了错误的图作为参考?有另一种LEA模式?
From this diagram, the second part of LEA, A should be PCoffset 9. However the value of A is 4660(in decimal) from ,A .FILL X1234, which is beyond the PCoffset 9 range, which is -256 to 255).
Can anyone explain what is going on? Am I using the wrong diagram as a reference? Is there another LEA mode?
推荐答案
每当你看到一个PCoffset为运code操作
Anytime you see a PCoffset as an opcode operand
LEA R2, A ; Loads the memory location of A into R2
; LEA, DR, PCoffset9
它告诉你,当你的code组装它实际上并没有将标签贴'A'到您的LEA命令。
It's telling you that when your code is assembled it doesn't actually place the label 'A' into your LEA command.
看看下面code:
.ORIG X3700 ; Not a code line in the simulator, only used by the assembler
LEA R0, A ; Line 1, starting at x3700
HALT ; Line 2
A .FILL X1234 ; Line 3, located at x3702
.END ; Not a code line in the simulator, only used by the assembler
现在在模拟器机关行实际上是这样的:
Now in the simulator the LEA line actually looks like this:
1110 000 000000001 ; Opcode 1110 is LEA
; 000 is our register R0
; 000000001 gives us how many memory locations away A is
而这正是偏移的手段。它要求的问题A走多少的内存块是我吗?如果我们的变量'A'是太多街区那么我们会因为我们不能再present,在价值偏移得到一个错误。
And that's what the offset means. It asks the question "How many blocks of memory is A away from me?" and if our variable 'A' is too many blocks away then we will get an error because we cannot represent that value in the offset.
这篇关于如何做一个的LEA指令店地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!